KnowController.php 1.1 KB

12345678910111213141516171819202122232425262728293031
  1. <?php
  2. namespace app\index\controller;
  3. use cmf\controller\HomeBaseController;
  4. use think\Db;
  5. class KnowController extends HomeBaseController
  6. {
  7. public function index()
  8. {
  9. $lists = Db::name('know')->whereIn('status',[1,2])->field('id,title,username,author,create_time')->paginate(20);
  10. $this->assign('lists',$lists);
  11. return $this->fetch();
  12. }
  13. public function show()
  14. {
  15. $param = $this->request->param();
  16. isset($param['id']) or $this->error('非法访问');
  17. $info = Db::name('know')->where('id',$param['id'])->find();
  18. $this->assign('info',$info);
  19. //seo
  20. $site_info = cmf_get_site_info();
  21. $seo_title = str_replace('|',$info['title'],$site_info['site_seo_title_knowlist']);
  22. $seo_keywords = str_replace('|',$info['title'],$site_info['site_seo_keywords_knowlist']);
  23. $seo_desc = str_replace('|',$info['title'],$site_info['site_seo_desc_knowlist']);
  24. $this->assign('seo_title',$seo_title);
  25. $this->assign('seo_keywords',$seo_keywords);
  26. $this->assign('seo_desc',$seo_desc);
  27. return $this->fetch();
  28. }
  29. }
  30. ?>