Category.php 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. <?php
  2. /**
  3. * 前台控制器
  4. * 书籍分类
  5. */
  6. namespace app\index\controller;
  7. use app\common\controller\Frontend;
  8. use app\common\model\Config;
  9. class Category extends Frontend
  10. {
  11. protected $layout = '';
  12. protected $categories_extime; //类别页面数据过期时间 默认7天
  13. protected $categorybooklist_extime; //类别下书籍列表过期时间 默认1天
  14. public function _initialize()
  15. {
  16. parent::_initialize();
  17. $this->categories_extime = 86400 * 7;
  18. $this->categorybooklist_extime = 86400;
  19. $this->view->assign('adminconfig',$this->adminconfig);
  20. }
  21. /**
  22. * 分类页
  23. */
  24. public function index()
  25. {
  26. $sex = input('sex');
  27. if(empty($sex)){
  28. $sex = 1;
  29. }
  30. $this->view->assign('sex',$sex);
  31. return $this->view->fetch();
  32. }
  33. /**
  34. * 分类书籍页
  35. * @param int $book_category_id
  36. * @return array
  37. */
  38. public function books()
  39. {
  40. $book_category_id = input('book_category_id');
  41. $category = model('BookCategory')->info($book_category_id);
  42. $this->assign('category', $category);
  43. return $this->view->fetch();
  44. }
  45. }