1、完善前端模板功能
2、完善伪静态规则设置
This commit is contained in:
@@ -33,6 +33,15 @@ class Base extends BaseC {
|
||||
$this->tpl_config['view_depr'] = '/';
|
||||
$this->tpl_config['view_dir_name'] = 'addons' . DIRECTORY_SEPARATOR . $this->request->param('addon') . DIRECTORY_SEPARATOR . 'view';
|
||||
}
|
||||
$template_path = str_replace("public", "", $this->tpl_config['view_dir_name']);
|
||||
$this->tpl_config['tpl_replace_string'] = [
|
||||
'__static__' => '/static',
|
||||
'__img__' => $template_path . DIRECTORY_SEPARATOR . 'static/images',
|
||||
'__css__' => $template_path . DIRECTORY_SEPARATOR . 'static/css',
|
||||
'__js__' => $template_path . DIRECTORY_SEPARATOR . 'static/js',
|
||||
'__plugins__' => '/static/plugins',
|
||||
'__public__' => $template_path . DIRECTORY_SEPARATOR . 'static',
|
||||
];
|
||||
|
||||
View::config($this->tpl_config);
|
||||
View::assign($this->data);
|
||||
|
||||
@@ -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']);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -42,11 +42,11 @@ class Base extends BaseC {
|
||||
if ($this->isMobile() && $config['mobile_themes']) {
|
||||
$mobile_themes = $config['mobile_themes'] ? $config['mobile_themes'] . DIRECTORY_SEPARATOR : "";
|
||||
$this->tpl_config['view_dir_name'] = 'public' . DIRECTORY_SEPARATOR . 'template' . DIRECTORY_SEPARATOR . $mobile_themes;
|
||||
if (!is_dir($this->app->getRootPath() . $this->tpl_config['view_dir_name'])) {
|
||||
if (!file_exists($this->app->getRootPath() . $this->tpl_config['view_dir_name'])) {
|
||||
$this->tpl_config['view_dir_name'] = 'public' . DIRECTORY_SEPARATOR . 'template' . DIRECTORY_SEPARATOR . $pc_themes;
|
||||
}
|
||||
}
|
||||
if(!is_dir($this->app->getRootPath() . $this->tpl_config['view_dir_name'])){
|
||||
if(!file_exists($this->app->getRootPath() . $this->tpl_config['view_dir_name'] . DIRECTORY_SEPARATOR . 'user')){
|
||||
$this->tpl_config['view_dir_name'] = 'public' . DIRECTORY_SEPARATOR . 'template' . DIRECTORY_SEPARATOR . 'default';
|
||||
}
|
||||
if ($template == '') {
|
||||
@@ -55,11 +55,11 @@ class Base extends BaseC {
|
||||
$template_path = str_replace("public", "", $this->tpl_config['view_dir_name']);
|
||||
$this->tpl_config['tpl_replace_string'] = [
|
||||
'__static__' => '/static',
|
||||
'__img__' => $template_path . 'static/images',
|
||||
'__css__' => $template_path . 'static/css',
|
||||
'__js__' => $template_path . 'static/js',
|
||||
'__img__' => $template_path . DIRECTORY_SEPARATOR . 'static/images',
|
||||
'__css__' => $template_path . DIRECTORY_SEPARATOR . 'static/css',
|
||||
'__js__' => $template_path . DIRECTORY_SEPARATOR . 'static/js',
|
||||
'__plugins__' => '/static/plugins',
|
||||
'__public__' => $template_path . 'static',
|
||||
'__public__' => $template_path . DIRECTORY_SEPARATOR . 'static',
|
||||
];
|
||||
|
||||
View::config($this->tpl_config);
|
||||
|
||||
Reference in New Issue
Block a user