Policy.php
2.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
<?php
namespace app\index\controller;
use app\common\controller\Frontend;
use think\Db;
class Policy extends Frontend
{
protected $noNeedLogin = '*';
protected $noNeedRight = '*';
protected $layout = 'default';
public function _initialize()
{
parent::_initialize(); // TODO: Change the autogenerated stub
$this->view->assign('index',$index='foot');//首页隐藏头部使用
}
public function index(){
$param = $this->request->param();
$page = null;
$p_category_id = Db::name('news_category')->where('title','政策制度')->where('school_id',$this->school_id)->value("id");
if(empty($param['category_id'])){
$category = Db::name('news_category')->where('pid',$p_category_id)->order("weigh","desc")->find();
}else{
$category = Db::name('news_category')->where('id',$param['category_id'])->find();
}
$category_list = Db::name('news_category')->where('pid',$p_category_id)->order("weigh","desc")->select();
$list = Db::name("news_content")->where("category_id", $category['id'])->paginate(3,false,["query"=>request()->param()]);
$page = $list->render();
$this->assign("category_list",$category_list);
$this->assign("list",$list);
$this->assign("category",$category);
$this->assign("page",$page);
return $this->view->fetch();
}
public function detail(){
$param = $this->request->param();
Db::name("news_content")->where(["id"=>$param['id']])->setInc("visit_count");
$p_category_id = Db::name('news_category')->where('title','政策制度')->where('school_id',$this->school_id)->value("id");
$category_list = Db::name('news_category')->where('pid',$p_category_id)->order("weigh","desc")->select();
$info = Db::name("news_content")->where("id", $param['id'])->find();
$category = Db::name('news_category')->where('id',$info['category_id'])->find();
$this->assign("category",$category);
$this->assign("category_list",$category_list);
$this->assign("info",$info);
return $this->view->fetch();
}
}