}
}
}
-
+
}
add_filter( 'parse_query', 'michsci_taxonomy_filter_post_type_request' );
extract( shortcode_atts( array( 'limit' => '10' ), $atts ) );
ob_start();
- if ( $product_id = filter_var( $_REQUEST['product'] ) ) {
+ echo '<form action=""><div class="row"><div class="small-12 medium-9 columns">';
+ echo michsci_get_terms_dropdown();
+ echo '</div><div 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);
-
- } if($cat_id = filter_var( $_REQUEST['term'])) {
- michsci_show_category($cat_id);
- }
- else {
+ } else if ( $cat_id = filter_var( $_REQUEST['category'], FILTER_VALIDATE_INT ) ) {
+ //michsci_list_categories($cat_id);
+ } else if ( !$catid_id && !$product_id ) {
michsci_list_products();
- michsci_list_categories();
+ //michsci_list_categories();
}
$output = ob_get_contents();
return $output;
}
+function michsci_get_terms_dropdown()
+{
+ $myterms = get_terms('michsci_category', array(
+ 'orderby' => 'name',
+ 'hide_empty' => true
+ ));
+ $output ="<select name=\"michsci_category\"><option value=\"\">Select Category</option>";
+ foreach ( $myterms as $term ) {
+ $term_taxonomy = $term->taxonomy;
+ $term_slug = $term->slug;
+ $term_name = $term->name;
+ $link = $root_url.'/'.$term_taxonomy.'/'.$term_slug;
+ $output .= '<option value="' . $term->term_id . '"';
+ if ($_REQUEST['michsci_category'] == $term->term_id) {
+ $output .= ' selected';
+ }
+ $output .= '>' . $term_name . '</option>';
+ }
+ $output .="</select>";
+ return $output;
+}
+
function michsci_list_products()
{
global $wpdb, $wp;
$iterator = 1;
foreach ( $products as $product ) {
+ $productTerms = wp_get_post_terms( $product->ID, 'michsci_category', 'name' );
+ $pTerm = $productTerms[0];
+ $product->term = $pTerm->name;
$product->end = false;
if ( $iterator == $totalProducts ) {
$product->end = true;
. "product=" . $product->ID;
++$iterator;
}
-
+ //echo '<pre>' . print_r($products, true) . '</pre>';
include 'views/list_products.php';
return;
}
-function michsci_list_categories()
+function michsci_list_categories( $cat_id = null )
{
global $wpdb, $wp;
$taxonomy = 'michsci_category';
- $taxonomy_terms = get_terms( $taxonomy, array(
- 'hide_empty' => false,
- 'parent'=> 0) );
+ $args = array(
+ 'hide_empty' => true,
+ 'pad_counts' => true
+ );
+ if ( $cat_id ) {
+ $args['child_of'] = $cat_id;
+ } else {
+ $args['parent'] = 0;
+ }
+ $taxonomy_terms = get_terms( $taxonomy, $args );
+
-
$totalTerms = count( $taxonomy_terms);
$current_url = esc_url( add_query_arg( $wp->query_string, '', home_url( $wp->request ) ) );
$iterator = 1;
function michsci_show_category($cat_id)
{
global $wpdb, $wp;
- $term = get_terms( $cat_id );
+ $term = get_terms(
+ 'michsci_category',
+ array(
+ 'child_of' => $cat_id,
+ 'hide_empty' => true,
+ //'parent' => $catid_id,
+ //'hierarchical' => false
+ )
+ );
+ echo '<pre>' . print_r( $term, true ) . '</pre>';
include 'views/category_detail.php';
return;
}
-
+
<div class="row">
-
- <?php if ( isset( $taxonomy_terms) && is_array( $taxonomy_terms ) ) : foreach ( $taxonomy_terms as $term ) : ?>
+
+<?php
+ if ( isset( $taxonomy_terms) && is_array( $taxonomy_terms ) ) :
+ foreach ( $taxonomy_terms as $term ) : ?>
+ <pre><?php //echo print_r( $term, true ) ?></pre>
<div class="small-12 medium-3 columns<?php if ($term->end){ echo ' end';}?>">
- <a href="<?php echo $term->href; ?>">
- <?php echo $term->name; ?>
- </a>
+ <div class="row">
+ <div class="small-12 columns"><a href="<?php echo $term->href; ?>">
+ <?php echo $term->description ?></a>
+ </div>
+ <div class="small-12 text-center columns">
+ <a href="<?php echo $term->href; ?>"> <?php echo $term->name; ?> </a>
+ </div>
+ </div>
</div>
- <?php endforeach; endif; ?>
-
+ <?php
+ endforeach;
+ endif; ?>
+
</div>
<div class="row">
<?php if ( isset( $products ) && is_array( $products ) ) : foreach ( $products as $product ) : ?>
<div class="small-12 medium-3 columns<?php if ($product->end){ echo ' end';}?>">
- <a href="<?php echo $product->href; ?>">
- <?php echo $product->post_title; ?>
-
- </a>
-
+ <div class="row">
+ <div class="small-12 columns"><a href="<?php echo $product->href; ?>">
+ <?php echo get_the_post_thumbnail( $product->ID, 'post-thumbnail' ); ?></a>
+ </div>
+ <div class="small-12 columns">
+ <a href="<?php echo $product->href; ?>"><?php echo $product->term; ?></a>
+ </div>
+ <div class="small-12 columns">
+ <a href="<?php echo $product->href; ?>"><strong><?php echo $product->post_title; ?></strong></a>
+ </div>
+ </div>
</div>
<?php endforeach; endif; ?>
-
-
</div>