if ( isset($atts['cat']) ) {
if ($prodCategory = get_term_by( 'slug', $atts['cat'], MICHSCI_CATEGORY_NAME ) ) {
$_REQUEST[MICHSCI_CATEGORY_NAME] = $prodCategory->term_id;
+ $cat_id = $_REQUEST[MICHSCI_CATEGORY_NAME];
+
}
}
-
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>
<span id="productSearch"> Search Products</span></div><div id="catDropdown" class="small-12 medium-4 columns">';
- echo michsci_get_terms_dropdown();
+ echo michsci_get_terms_dropdown($cat_id);
echo '</div><div id="searchContainer" class="small-12 medium-3 columns"></form> <form class="searchform" role="search" method="get" action="' .get_bloginfo('url') .'">
<input class="search-input" placeholder="SEARCH" value="" name="s" type="text">
<input id="input" class="search-button" name="searchButton" value="Search" type="submit">
* @access public
* @return void
*/
-function michsci_get_terms_dropdown()
+function michsci_get_terms_dropdown($cat_id)
{
$taxonomyName = MICHSCI_CATEGORY_NAME;
+ if($cat_id){
+ $cats_child = get_term_children($cat_id, $taxonomyName);
+ foreach($cats_child as $cat){
+ $output ="<select id='categoryDropdown' name=\"" . MICHSCI_CATEGORY_NAME . "\"><option value=\"\">Select " . MICHSCI_CATEGORY_SINGLE . "</option>";
+ $main = get_term($cat_id, MICHSCI_CATEGORY_NAME);
+ $output .= '<option value="' . $cat . '"';
+ if ($_REQUEST[MICHSCI_CATEGORY_NAME] == $cat->term_id) {
+ $output .= ' selected';
+ }
+ $catName = get_term($cat, MICHSCI_CATEGORY_NAME);
+ $output .= '>' . $catName->name. '</option>';
+ $output .="</select>";
+ }
+ } else {
$parent_terms = get_terms($taxonomyName, array('parent' => 0, 'orderby' => 'name', 'hide_empty' => false));
$output ="<select id='categoryDropdown' name=\"" . MICHSCI_CATEGORY_NAME . "\"><option value=\"\">Select " . MICHSCI_CATEGORY_SINGLE . "</option>";
// get parent categories
$output .= ' selected';
}
$output .= '>' . "   " . $child->name . '</option>';
-// foreach($grandchildren as $grandchild){
-// $output .= '<option value="' . $grandchild->term_id . '"';
-// if ($_REQUEST[MICHSCI_CATEGORY_NAME] == $grandchild->term_id) {
-// $output .= ' selected';
-// }
-// $output .= '>' . "      " . $grandchild->name . '</option>';
-// }
}
}
- $output .="</select>";
+ $output .="</select>"; }
return $output;
}
<?php if(!isset($_COOKIE['catView']) || $_COOKIE['catView'] == "grid"){ ?>
<div id="categoriesGridView" class="row">
- <?php $uri= $_SERVER['REQUEST_URI'];
- $catNum = substr($uri, -2);
- if(is_numeric($catNum) == false){
- $catNum = substr($catNum, -1);
- }
- echo category_description($catNum);
- ?>
+
<?php
if ( isset( $taxonomy_terms) && is_array( $taxonomy_terms ) ) :
foreach ( $taxonomy_terms as $term ) : ?>
<a href="<?php echo $term->href; ?>"> <?php echo $term->name; ?> </a>
</div>
</div>
-
</div>
</div>
<?php
<?php } ?>
<?php if(!isset($_COOKIE['catView']) || $_COOKIE['catView'] == "list"){ ?>
<div id="categoriesListView" class="row">
- <?php $uri= $_SERVER['REQUEST_URI'];
- $catNum = substr($uri, -2);
- if(is_numeric($catNum) == false){
- $catNum = substr($catNum, -1);
- }
- echo category_description($catNum);
- ?>
+
<?php
if ( isset( $taxonomy_terms) && is_array( $taxonomy_terms ) ) :
foreach ( $taxonomy_terms as $term ) : ?>
<?php if(!isset($_COOKIE['view']) || $_COOKIE['view'] == "grid"){ ?>
<div id="gridView" class="row">
- <?php $uri= $_SERVER['REQUEST_URI'];
- $catNum = substr($uri, -2);
- if(is_numeric($catNum) == false){
- $catNum = substr($catNum, -1);
- }
+ <?php
+
+ $catNum = $_REQUEST[MICHSCI_CATEGORY_NAME];
echo category_description($catNum);
+
?>
<?php if ( isset( $products ) && is_array( $products ) ) : foreach ( $products as $product ) : ?>
-
<?php $tags = wp_get_post_terms($product->ID,'michsci_tag'); ?>
<div class="<?php foreach ($tags as $tag)echo $tag->slug . " ";?> product grid small-12 medium-4 columns<?php if ($product->end){ echo ' end';}?>">
<?php if($_COOKIE['view'] == "list"){ ?>
<div id="listView" class="row">
- <?php $uri= $_SERVER['REQUEST_URI'];
- $catNum = substr($uri, -2);
- if(is_numeric($catNum) == false){
- $catNum = substr($catNum, -1);
- }
+ <?php
+ $catNum = $_REQUEST[MICHSCI_CATEGORY_NAME];
echo category_description($catNum);
?>
<?php if ( isset( $products ) && is_array( $products ) ) : foreach ( $products as $product ) : ?>