BlogCategoryWidget.class.php 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. <?php
  2. /**
  3. * 小梦科技资源nanodreamtech.com
  4. *
  5. * ==========================================================================
  6. * @link https://www.nanodreamtech.com/
  7. * @copyright Copyright (c) 2015 liofis.com.
  8. * @license https://www.nanodreamtech.com/license.html License
  9. * ==========================================================================
  10. *
  11. * @author fish
  12. *
  13. */
  14. namespace Home\Widget;
  15. use Think\Controller;
  16. /**
  17. * 博客分类
  18. */
  19. class BlogCategoryWidget extends Controller{
  20. function blog_category_show(){
  21. if (!$blog_category = S('blog_category')) {
  22. $hashids = new \Lib\Hashids(C('PWD_KEY'), C('URL_ID'));
  23. $list=M('BlogCategory')->select();
  24. $category=list_to_tree($list);
  25. foreach ($category as $k => $v) {
  26. $category[$k]['id']=$hashids->encode($v['id']);
  27. if(isset($v['children']))
  28. foreach ($v['children'] as $k1 => $v1) {
  29. $category[$k]['children'][$k1]['id']=$hashids->encode($v1['id']);
  30. }
  31. }
  32. S('blog_category', $category);
  33. $blog_category=$category;
  34. }
  35. $this->blog_category=$blog_category;
  36. $this->display('Widget:blog_category');
  37. }
  38. }