1、完善前端模板功能

2、完善伪静态规则设置
This commit is contained in:
2020-04-17 16:46:32 +08:00
parent ce9b63dda1
commit 83ce571a3f
6 changed files with 135 additions and 57 deletions

View File

@@ -35,13 +35,16 @@ class Content extends Base {
$category = Category::where('model_id', $this->modelInfo['id'])->column("*", "id");
$list = $this->model->where($map)->order($order)->paginate($this->request->pageConfig);
$teamplate = 'front@content/' . $this->modelInfo['name'] . '/index';
$this->data = [
'model' => $this->modelInfo,
'category' => $category,
'list' => $list,
'page' => $list->render()
];
return $this->fetch();
return $this->fetch($teamplate);
}
/**
@@ -65,6 +68,15 @@ class Content extends Base {
}
$list = $this->model->where($map)->order($order)->paginate($this->request->pageConfig);
//当前栏目
$cate = $category[$param['id']];
if (isset($cate['template_lists']) && $cate['template_lists']) {
$teamplate = 'front@content/' . $this->modelInfo['name'] . '/' . $cate['template_lists'];
} else {
$teamplate = 'front@content/' . $this->modelInfo['name'] . '/list';
}
$this->data = [
'model' => $this->modelInfo,
'id' => (int) $param['id'],
@@ -72,7 +84,7 @@ class Content extends Base {
'list' => $list,
'page' => $list->render()
];
return $this->fetch();
return $this->fetch($teamplate);
}
/**
@@ -86,24 +98,39 @@ class Content extends Base {
$map[] = ['id', "=", $param['id']];
$detail = $this->model->where($map)->find();
$pmap = [
['category_id', '=', $detail['category_id']],
['id', '<', $param['id']]
];
if (isset($detail['category_id']) && $detail['category_id']) {
$pmap = [
['category_id', '=', $detail['category_id']],
['id', '<', $param['id']]
];
$nmap = [
['category_id', '=', $detail['category_id']],
['id', '>', $param['id']]
];
}else{
$pmap = [
['id', '<', $param['id']]
];
$nmap = [
['id', '>', $param['id']]
];
}
$prev = Db::name(ucfirst($this->modelInfo['name']))->where($pmap)->order('id desc')->find();
$nmap = [
['category_id', '=', $detail['category_id']],
['id', '>', $param['id']]
];
$next = Db::name(ucfirst($this->modelInfo['name']))->where($nmap)->order('id asc')->find();
if (isset($detail['template_detail']) && $detail['template_detail']) {
$teamplate = 'front@content/' . $this->modelInfo['name'] . '/' . $detail['template_detail'];
} else {
$teamplate = 'front@content/' . $this->modelInfo['name'] . '/detail';
}
$this->data = [
'model' => $this->modelInfo,
'info' => $detail,
'prev' => $prev,
'next' => $next
];
return $this->fetch();
return $this->fetch($teamplate);
}
/**
@@ -133,7 +160,7 @@ class Content extends Base {
}
protected function setModel(){
$this->modelInfo = Model::where('name', $this->request->param('name'))->find()->append(['grid_list', 'attr_group'])->toArray();
$this->modelInfo = Model::where('id', $this->request->param('model_id'))->find()->append(['grid_list', 'attr_group'])->toArray();
$this->model = Db::name($this->modelInfo['name']);
}
}