NewController.php
2.0 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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
<?php
namespace app\portal\controller;
use cmf\controller\HomeBaseController;
use app\portal\model\PortalCategoryModel;
use think\Db;
use think\Paginator;
class NewController extends HomeBaseController{
public function _initialize(){
parent::_initialize();
$data = Db::name('slide_item') -> where('slide_id',3) -> find();
$this -> assign('logo',$data);
$shuju = Db::name('nav_menu') -> select();
$data2 = $this -> daohang($shuju);
$this -> assign('data2',$data2);
}
public function daohang($data,$pid=0){
$arr = [];
foreach ($data as $key => $value) {
if($value['parent_id'] == $pid){
$value['son'] = $this -> daohang($data,$value['id']);
$arr[] = $value;
}
}
return $arr;
}
//显示新闻列表
public function newlist(){
$ids = Db::name('portal_category_post') -> where('category_id',16) -> select();
foreach ($ids as $key => $value) {
$arr[] = $value['post_id'];
}
$data = Db::name('portal_post') -> where('id','in',$arr) -> where('delete_time',0) -> order('create_time desc') -> paginate(3);
$this->assign('page', $data->render());
$this -> assign('data',$data);
return $this -> fetch();
}
//显示新闻内容
public function index(){
$id = $this -> request -> param();
$data = Db::name('portal_post') -> where('id',$id['id']) -> find();
$data['post_content'] = cmf_replace_content_file_url(htmlspecialchars_decode($data['post_content']));
$this -> assign('data',$data);
return $this -> fetch();
}
//显示管理内容 联系我们
public function guanli(){
$id = $this -> request -> param();
$data = Db::name('portal_category_post') -> where("category_id = ".$id['id']." and status = 1") -> find();
$shuju = Db::name('portal_post') -> where('id',$data['post_id']) -> find();
$shuju['post_content'] = cmf_replace_content_file_url(htmlspecialchars_decode($shuju['post_content']));
$this -> assign('shuju',$shuju);
return $this -> fetch();
}
}
?>