ListController.php
5.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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
<?php
// +----------------------------------------------------------------------
// | bronet [ 以客户为中心 以奋斗者为本 ]
// +----------------------------------------------------------------------
// | Copyright (c) 2013-2017 http://www.bronet.cn All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | Author: 老猫 <bronet@126.com>
// +----------------------------------------------------------------------
namespace app\portal\controller;
use cmf\controller\HomeBaseController;
use app\portal\model\PortalCategoryModel;
use think\Db;
class ListController 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 index()
{
$id = $this->request->param('id', 0, 'intval');
$portalCategoryModel = new PortalCategoryModel();
$category = $portalCategoryModel->where('id', $id)->where('status', 1)->find()->toArray();
$this->assign('category', $category);
$path = explode('-', $category['path']);
//产品介绍
if($path[1] == 12){
/* $jdata[] = Db::name('portal_category') -> where('id',$path[2]) -> find();
$jdata[0]['son'] = Db::name('portal_category') -> where('parent_id',$path[2]) -> select();
$this -> assign('jdata',$jdata);
$data = Db::name('portal_category') -> select();
$shuju2 = $this -> wuxianx($data);
foreach ($shuju2 as $key => $value) {
$arr[] = $value['id'];
}
foreach ($arr as $key => $value) {
$arr1[] = Db::name('portal_category_post') -> where('category_id',$value) -> select();
}
foreach ($arr1 as $key => $value) {
foreach ($value as $k => $va) {
$arr3[] = $va['post_id'];
}
}*/
$data = Db::name('portal_category') -> select();
$shuju = $this -> wuxian($data);
$this -> assign('jdata',$shuju);
if(count($path) == 4){
//将最新文章的说明文献coa显示
$cos_data = Db::name('docu_coa') -> where('post_id',$category['id']) -> select();
$this -> assign('cos_data',$cos_data);
//显示文章
$post_data = Db::name('portal_category_post') -> where('category_id',$category['id']) -> find();
$wh_data = Db::name('portal_post') -> where('id',$post_data['post_id']) -> find();
$wh_data['post_content'] = cmf_replace_content_file_url(htmlspecialchars_decode($wh_data['post_content']));
$this -> assign('zuixin',$wh_data);
$this -> assign('category',$category['id']);
}else{
$id = Db::name('portal_category_post') -> where('category_id',$path[2]) -> find();
$wz_data = Db::name('portal_post') -> where('id',$id['post_id']) -> find();
$this -> assign('zuixin',$wz_data);
//将最新文章的说明文献coa显示
$post_data = Db::name('portal_category_post') -> where('post_id',$zzz['id']) -> find();
$cos_data = Db::name('docu_coa') -> where('post_id',$post_data['category_id']) -> select();
$this -> assign('cos_data',$cos_data);
}
}
//新闻分类
if($path[2] == 16){
$this -> redirect('New/newlist');
}
//管理团队
if($path[2] == 23 || $path[2] == 24){
$this->redirect('New/guanli',['id'=>$category['id']]);
}
//支持 预留
if($path[1] == 25 || $path[1] == 18){
$this -> redirect('Support/index',['id'=>$path[2],'pid'=>$path[1]]);
}
$listTpl = empty($category['list_tpl']) ? 'list' : $category['list_tpl'];
return $this->fetch('/' . $listTpl);
}
public function wuxianx($data,$pid=12){
static $arr=[];
foreach ($data as $key => $value) {
if($value['parent_id'] == $pid){
$arr[] = $value;
$this -> wuxianx($data,$value['id']);
}
}
return $arr;
}
public function wuxian($data,$pid=12){
$arr = [];
foreach ($data as $key => $value) {
if($value['parent_id'] == $pid){
$value['son'] = $this -> daohang($data,$value['id']);
$arr[] = $value;
}
}
return $arr;
}
}