Index.php 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. <?php
  2. namespace app\index\controller;
  3. use app\index\model\CommonModel;
  4. use app\index\model\ColumnModel;
  5. use app\index\model\ArticleModel;
  6. use app\index\controller\Base;
  7. class Index extends Base
  8. {
  9. public function index()//主页
  10. {
  11. $cum = new ColumnModel();//导航栏表
  12. $com = new CommonModel();//工具信息表
  13. // $cums = $cum->select();
  14. $column_id=input('column_id');
  15. //查询当前导航栏表名称
  16. $cid=$cum->find($column_id);
  17. //查询当前工具信息表下的信息
  18. $goods=$com->where(array('column_id'=>$column_id))->order('sort desc')->select();
  19. $this->assign([
  20. 'goods'=>$goods,
  21. 'cid'=>$cid,
  22. ]);
  23. return view();
  24. }
  25. public function title(){
  26. $id = input('id');
  27. $titles = db('good')->where('id',$id)->find();
  28. $this->assign([
  29. 'titles'=>$titles,
  30. ]);
  31. return view($titles['url']);
  32. }
  33. public function Homepage(){//文章页和工具页(主页)
  34. $aticle = new ArticleModel();//文章表
  35. $good = new CommonModel();//工具信息表
  36. $gds = $good->alias('a')
  37. ->field('a.*,b.catename')
  38. ->join('column b','a.column_id=b.id')->limit(8)->order('sort desc')->select();
  39. $ar = $aticle->limit(9)->order('time desc')->select();
  40. $this->assign([
  41. 'ar'=>$ar,
  42. 'gds'=>$gds,
  43. ]);
  44. return view();
  45. }
  46. public function Artis(){//文章页
  47. $aticle = new ArticleModel();//文章表
  48. $articles = $aticle->order('time desc')->paginate(10);
  49. $this->assign([
  50. 'articles'=>$articles,
  51. ]);
  52. return view();
  53. }
  54. }