function widget($args, $instance) { extract($args); $title = apply_filters('xt_widget_title', empty($instance['title']) ? '' : $instance['title'], $instance, $this->id_base); $cids = apply_filters('xt_filter_ids', $instance['cids']); $style = $instance['style']; global $xt, $xt_catalog, $wp_query; $s = ''; echo $before_widget; if (!empty($cids)) { $cids = explode(',', $cids); $roots = xt_catalogs_share_sub(0); $catalogs = array(); if (!empty($roots)) { foreach ($roots as $root) { if (in_array($root->id, $cids)) { $catalogs[] = $root; } } } $fCid = $cids[0]; $sCid = 0; if ($xt->is_shares && !empty($xt_catalog)) { $xt_share_param = $wp_query->query_vars['xt_param']; $s = isset($xt_share_param['s']) ? $xt_share_param['s'] : ''; $parentCid = $xt_catalog->id; if ($xt_catalog->parent) { $parentCid = $xt_catalog->parent; $sCid = $xt_catalog->id; } if (in_array($parentCid, $cids)) { $fCid = $parentCid; } } $childs = xt_catalogs_share_sub($fCid); switch ($style) { case 'mogujie': _xt_widget_catalog_share_mogujie($fCid, $sCid, $s, $catalogs, $childs); break; case 'fandongxi': _xt_widget_catalog_share_fandongxi($fCid, $sCid, $s, $catalogs, $childs); break; } } if ($xt->is_shares) { $xt_share_param = $wp_query->query_vars['xt_param']; $s = isset($xt_share_param['s']) ? $xt_share_param['s'] : ''; $h3 = !empty($s) ? $s : (!empty($xt_catalog) ? $xt_catalog->title : ''); $filterCid = ''; $filterPrice = $xt_share_param['price']; $filterSortOrder = $xt_share_param['sortOrder']; if (!empty($xt_catalog)) { $filterCid = $xt_catalog->id; } $prices = xt_prices(); ?> <div class="row-fluid clearfix" style="margin-top:10px;"> <h3 class="pull-left text-default" style="margin:0px;"><?php echo $h3; ?> </h3> <div class="pull-left" style="padding:8px 0px 3px 20px;"> 排序: <div class="btn-group"> <a class="btn btn-small <?php echo $filterSortOrder == 'popular' ? 'btn-primary' : ''; ?> " href="<?php echo xt_get_shares_search_url(array('cid' => $filterCid, 's' => $s, 'sortOrder' => 'popular', 'price' => $filterPrice)); ?> " data-value="popular">潮流</a> <a class="btn btn-small <?php echo $filterSortOrder == 'newest' ? 'btn-primary' : ''; ?> " href="<?php echo xt_get_shares_search_url(array('cid' => $filterCid, 's' => $s, 'sortOrder' => 'newest', 'price' => $filterPrice)); ?> " data-value="newest">最新</a> <a class="btn btn-small <?php echo $filterSortOrder == 'hot' ? 'btn-primary' : ''; ?> " href="<?php echo xt_get_shares_search_url(array('cid' => $filterCid, 's' => $s, 'sortOrder' => 'hot', 'price' => $filterPrice)); ?> " data-value="hot">最热</a> </div> 价格: <div class="btn-group"> <a class="btn btn-small <?php echo $filterPrice == '' ? 'btn-primary' : ''; ?> " href="<?php echo xt_get_shares_search_url(array('cid' => $filterCid, 's' => $s, 'sortOrder' => $filterSortOrder, 'price' => '')); ?> " data-value="">全部</a> <a class="btn btn-small <?php echo $filterPrice == 'low' ? 'btn-primary' : ''; ?> " href="<?php echo xt_get_shares_search_url(array('cid' => $filterCid, 's' => $s, 'sortOrder' => $filterSortOrder, 'price' => 'low')); ?> " data-value="low"><?php echo $prices['low']['end']; ?> 元</a> <a class="btn btn-small <?php echo $filterPrice == 'medium' ? 'btn-primary' : ''; ?> " href="<?php echo xt_get_shares_search_url(array('cid' => $filterCid, 's' => $s, 'sortOrder' => $filterSortOrder, 'price' => 'medium')); ?> " data-value="medium"><?php echo $prices['medium']['end']; ?> 元</a> <a class="btn btn-small <?php echo $filterPrice == 'high' ? 'btn-primary' : ''; ?> " href="<?php echo xt_get_shares_search_url(array('cid' => $filterCid, 's' => $s, 'sortOrder' => $filterSortOrder, 'price' => 'high')); ?> " data-value="high"><?php echo $prices['high']['end']; ?> 元</a> <a class="btn btn-small <?php echo $filterPrice == 'higher' ? 'btn-primary' : ''; ?> " href="<?php echo xt_get_shares_search_url(array('cid' => $filterCid, 's' => $s, 'sortOrder' => $filterSortOrder, 'price' => 'higher')); ?> " data-value="higher">更高</a> </div> </div> </div> <?php } echo $after_widget; }
$terms = array(); $terms_sub = array(); $terms_tag = array(); $terms_select = 0; $terms_parent = 0; $terms_tag_parent = 0; $tag_select = isset($xt_share_param['s']) ? $xt_share_param['s'] : ''; if (!empty($xt_catalog)) { //指定了分类 $terms_tag_parent = $xt_catalog->id; $terms_select = $xt_catalog->id; $terms_parent = $xt_catalog->parent; $terms_sub = $terms = xt_catalogs_share_sub($terms_select); } //catalog $terms = xt_catalogs_share_sub($terms_parent); //tag $query_tags = query_tags(array('cid' => $terms_select)); $terms_tag = $query_tags['tags']; if (!empty($terms)) { ?> <div class="span3 xt-share xt-share-catalog"> <div class="thumbnail"> <div class="caption"> <?php echo '<a href="' . xt_get_shares_search_url(array_merge($xt_share_param, array('cid' => $terms_parent, 's' => '', 'sortOrder' => '', 'price' => '', 'page' => 1))) . '" ' . ($terms_select == 0 ? ' class="label label-tag active"' : 'class="label label-tag"') . '>全部</a>'; foreach ($terms as $term) { if ($term->is_front) { echo '<a href="' . xt_get_shares_search_url(array_merge($xt_share_param, array('cid' => $term->id, 's' => '', 'sortOrder' => '', 'price' => '', 'page' => 1))) . '"' . ($terms_select == $term->id ? ' class="label label-tag active"' : 'class="label label-tag"') . '>' . $term->title . '</a>'; } }