Common.php
1.77 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
<?php
namespace app\mobile\controller;
use think\Db;
use clt\Leftnav;
use think\Controller;
class Common extends Controller
{
public function initialize()
{
if(!isMobile()){
$this->redirect('home/index/index');
}
$sys = cache('System');
$this->assign('sys',$sys);
//导航
$cate = cache('cate');
if(!$cate){
$column_one = Db::name('category')->where([['parentid','=',0],['ismenu','=',1]])->order('sort')->select();
$column_two = Db::name('category')->where('ismenu',1)->order('sort')->select();
$tree = new Leftnav ();
$cate = $tree->index_top($column_one,$column_two);
cache('cate', $cate, 3600);
}
$this->assign('category',$cate);
//二级导航
$thisCat = Db::name('category')->where('id',input('catId'))->find();
$this->assign('title',$thisCat['title']);
$this->assign('keywords',$thisCat['keywords']);
$this->assign('description',$thisCat['description']);
define('DBNAME',strtolower($thisCat['module']));
$this->pagesize = $thisCat['pagesize']>0 ? $thisCat['pagesize'] : '';
//广告
$adList = cache('adList');
if(!$adList){
$adList = Db::name('ad')->where(['type_id'=>1,'open'=>1])->order('sort asc')->limit('4')->select();
cache('adList', $adList, 3600);
}
$this->assign('adList', $adList);
//畅言
$plugin = db('plugin')->where(['code'=>'changyan'])->find();
$this->changyan = unserialize($plugin['config_value']);
$this->assign('changyan', $this->changyan);
}
//空操作
public function _empty(){
return $this->error('空操作,返回上次访问页面中...');
}
}