GoodsCategoryWidget.class.php 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. <?php
  2. /**
  3. * lionfish 商城系统
  4. *
  5. * ==========================================================================
  6. * @link http://www.liofis.com/
  7. * @copyright Copyright (c) 2015 liofis.com.
  8. * @license http://www.liofis.com/license.html License
  9. * ==========================================================================
  10. *
  11. * @author fish
  12. *
  13. */
  14. namespace Home\Widget;
  15. use Think\Controller;
  16. /**
  17. * 商品分类
  18. */
  19. class GoodsCategoryWidget extends Controller{
  20. public function goods_category_show()
  21. {
  22. $gid = I('get.gid',0);
  23. $key='index_goodscategory_cache';
  24. if (!$hot_list = S($key)) {
  25. $hot_list = M('goods_category')->where( array('is_hot' => 1) )->order('sort_order desc')->select();
  26. S($key, $hot_list);
  27. }
  28. $this->gid = $gid;
  29. $this->hot_list = $hot_list;
  30. $this->display('Widget:index_goods_category');
  31. }
  32. function blog_category_show(){
  33. if (!$blog_category = S('blog_category')) {
  34. $hashids = new \Lib\Hashids(C('PWD_KEY'), C('URL_ID'));
  35. $list=M('BlogCategory')->select();
  36. $category=list_to_tree($list);
  37. foreach ($category as $k => $v) {
  38. $category[$k]['id']=$hashids->encode($v['id']);
  39. if(isset($v['children']))
  40. foreach ($v['children'] as $k1 => $v1) {
  41. $category[$k]['children'][$k1]['id']=$hashids->encode($v1['id']);
  42. }
  43. }
  44. S('blog_category', $category);
  45. $blog_category=$category;
  46. }
  47. $this->blog_category=$blog_category;
  48. $this->display('Widget:blog_category');
  49. }
  50. }