From 2eb6689f6e135e905f0e720512df596ad02f11fe Mon Sep 17 00:00:00 2001 From: Anthony Talarico Date: Fri, 29 Jan 2016 08:15:06 -0500 Subject: [PATCH] testing search query on dev55 --- index.php | 38 ++++++++++++++++++++++++++------------ views/list_categories.php | 12 ++++++++++++ 2 files changed, 38 insertions(+), 12 deletions(-) diff --git a/index.php b/index.php index 63bb1eb..e2a37bc 100644 --- a/index.php +++ b/index.php @@ -446,26 +446,28 @@ function michsci_shortcode($atts) $cat_id = $prodCategory->term_id; } } + global $wp; echo '
'; echo michsci_get_terms_dropdown($cat_id); - echo '
'; - if ( $product_id = filter_var( $_REQUEST['product'], FILTER_VALIDATE_INT ) ) { michsci_show_product($product_id); } else if ( $cat_id = filter_var( $_REQUEST['category'], FILTER_VALIDATE_INT ) ) { - //michsci_list_categories($cat_id); + michsci_list_categories($cat_id); } else if ( !$catid_id && !$product_id ) { - michsci_list_products($cat_id); + $text_query = $_REQUEST['tsearch']; + michsci_list_products($text_query); michsci_list_categories(); - } - + } + $output = ob_get_contents(); ob_end_clean(); return $output; @@ -481,6 +483,11 @@ function michsci_shortcode($atts) */ function michsci_get_terms_dropdown($cat_id) { +// $test = $_REQUEST['tsearch']; +// $filterTest = filter_var($test, FILTER_SANITIZE_STRING); +// echo $filterTest; + + $taxonomyName = MICHSCI_CATEGORY_NAME; if($cat_id){ $main = get_term($cat_id, MICHSCI_CATEGORY_NAME); @@ -526,8 +533,6 @@ function michsci_get_terms_dropdown($cat_id) } } } - - $output .=""; } return $output; } @@ -541,15 +546,24 @@ function michsci_get_terms_dropdown($cat_id) * @access public * @return void */ -function michsci_list_products($cat_id) +function michsci_list_products($text_query) { global $wpdb, $wp; + $cat = get_term($cat_id, MICHSCI_CATEGORY_NAME); $args = array( 'posts_per_page' => -1, - 'post_type' => 'miproduct' + 'post_type' => 'miproduct', + 's' => $text_query +// 'meta_query' => array( +// array( +// 'key' => 'post_title', +// 'value' => $text_query, +// 'compare' => 'LIKE' +// ) +// ) + // add meta query here ); - $misch_category = ( isset( $_REQUEST[MICHSCI_CATEGORY_NAME] ) ) ? filter_var( $_REQUEST[MICHSCI_CATEGORY_NAME] ) : false; diff --git a/views/list_categories.php b/views/list_categories.php index 99592db..84c7a5d 100644 --- a/views/list_categories.php +++ b/views/list_categories.php @@ -1,4 +1,16 @@ + "); ?> + +
+ ' . Products . ''." > "; ?> +' . $relative->slug . "" . " > "; +} ?> + name . print_r($ancestors, true) . "
"; ?> +
+ +