echo '<form id="catSubmit" action=""><div class="row catSearch"><div id="viewBtns" class="12-small medium-3 columns"> <button id="grid" type="button">Grid</button> <button id="list"type="button">list</button>
</div><div id="catDropdown" class="small-12 medium-6 columns">';
-
echo michsci_get_terms_dropdown();
echo '</div><div id="catSearchBtn" class="small-12 medium-3 columns"><input type="submit" value="search" class="button"></div></div>';
echo '</form>';
+
+
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 ) ) {
function michsci_get_terms_dropdown()
{
-
-
$taxonomyName = "michsci_category";
$parent_terms = get_terms($taxonomyName, array('parent' => 0, 'orderby' => 'name', 'hide_empty' => false));
$output ="<select id='categoryDropdown' name=\"michsci_category\"><option value=\"\">Select Category</option>";
$child_terms = get_terms($taxonomyName, array('child_of' => $parent->term_id, 'orderby' => 'name', 'hide_empty' => false));
$output .= '<option value="' . $parent->term_id . '"';
if ($_REQUEST['michsci_category'] == $parent->term_id) {
- $output .= ' selected';
- }
- $output .= '>' . $parent->name . '</option>';
+ $output .= ' selected';
+ }
+ $output .= '>' . $parent->name . '</option>';
foreach($child_terms as $child){
+ $grandchildren = get_terms($taxonomyName, array('child_of' => $child->term_id, 'orderby' => 'name', 'hide_empty' => false));
$output .= '<option value="' . $child->term_id . '"';
if ($_REQUEST['michsci_category'] == $child->term_id) {
- $output .= ' selected';
- }
- $output .= '>' . "   " . $child->name . '</option>';
-
+ $output .= ' selected';
+ }
+ $output .= '>' . "   " . $child->name . '</option>';
+ foreach($grandchildren as $grandchild){
+ $output .= '<option value="' . $grandchild->term_id . '"';
+ if ($_REQUEST['michsci_category'] == $grandchild->term_id) {
+ $output .= ' selected';
+ }
+ $output .= '>' . "      " . $grandchild->name . '</option>';
+ }
}
}
$output .="</select>";
return $output;
}
+
function michsci_list_products()
{
global $wpdb, $wp;