1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859 |
- <?php
- /**
- * 小梦科技资源nanodreamtech.com
- *
- * ==========================================================================
- * @link https://www.nanodreamtech.com/
- * @copyright Copyright (c) 2015 liofis.com.
- * @license https://www.nanodreamtech.com/license.html License
- * ==========================================================================
- *
- * @author fish
- *
- */
- namespace Home\Widget;
- use Think\Controller;
- /**
- * 商品分类
- */
- class GoodsCategoryWidget extends Controller{
-
- public function goods_category_show()
- {
- $gid = I('get.gid',0);
- $key='index_goodscategory_cache';
- if (!$hot_list = S($key)) {
- $hot_list = M('goods_category')->where( array('is_hot' => 1) )->order('sort_order desc')->select();
- S($key, $hot_list);
- }
- $this->gid = $gid;
-
- $this->hot_list = $hot_list;
- $this->display('Widget:index_goods_category');
- }
-
- function blog_category_show(){
- if (!$blog_category = S('blog_category')) {
-
- $hashids = new \Lib\Hashids(C('PWD_KEY'), C('URL_ID'));
- $list=M('BlogCategory')->select();
- $category=list_to_tree($list);
-
- foreach ($category as $k => $v) {
- $category[$k]['id']=$hashids->encode($v['id']);
- if(isset($v['children']))
- foreach ($v['children'] as $k1 => $v1) {
- $category[$k]['children'][$k1]['id']=$hashids->encode($v1['id']);
- }
- }
-
- S('blog_category', $category);
- $blog_category=$category;
- }
-
- $this->blog_category=$blog_category;
-
- $this->display('Widget:blog_category');
- }
-
- }
|