每个模板都有自己的头部导航,文章和分类

This commit is contained in:
2020-05-12 22:18:15 +08:00
parent 2f7ec6793e
commit 713ed8e432
21 changed files with 80 additions and 49 deletions

View File

@@ -14,31 +14,40 @@ class Common extends BaseController
{
parent::initialize();
$list_header_nav = Nav::where('type', 1)->order('sort asc')->where('status', 1)->select();
View::assign('list_header_nav', $list_header_nav);
$list_nav_slide = Nav::where('type', 3)->order('sort asc')->where('status', 1)->select();
View::assign('list_nav_slide', $list_nav_slide);
$list_nav_friend_url = Nav::where('type', 2)->order('sort asc')->where('status', 1)->select();
View::assign('list_nav_friend_url', $list_nav_friend_url);
if (!empty($this->indexTplMethod)) {
if (method_exists($this, $this->indexTplMethod)) {
$this->{$this->indexTplMethod}();
}
}
if (!empty($this->indexTplMethodCurrentAction)) {
if (method_exists($this, $this->indexTplMethodCurrentAction)) {
$this->{$this->indexTplMethodCurrentAction}();
}
}
}
public function __blog()
{
$list_header_nav = Nav::where('type', 'blog_header_nav')->order('sort asc')->where('status', 1)->select();
View::assign('list_header_nav', $list_header_nav);
}
public function __documents()
{
$list_header_nav = Nav::where('type', 'document_header_nav')->order('sort asc')->where('status', 1)->select();
View::assign('list_header_nav', $list_header_nav);
}
public function __easyBlue()
{
$list_header_nav = Nav::where('type', 10)->order('sort asc')->where('status', 1)->select();
View::assign('list_header_nav', $list_header_nav);
$list_nav_index_block_1 = Nav::where('type', 6)->order('sort asc')->where('status', 1)->select();
View::assign('list_nav_index_block_1', $list_nav_index_block_1);
$list_nav_index_block_2 = Nav::where('type', 7)->order('sort asc')->where('status', 1)->select();
@@ -47,12 +56,15 @@ class Common extends BaseController
public function __articles()
{
$list_category_first_level = Category::where('level', 1)->where('status', 1)->select();
$list_header_nav = Nav::where('type', 11)->order('sort asc')->where('status', 1)->select();
View::assign('list_header_nav', $list_header_nav);
$list_category_first_level = Category::where('level', 1)->where('status', 1)->where('type',3)->select();
$this->assign('list_category_first_level', $list_category_first_level);
$list_nav_more = Nav::where('type', 8)->order('sort asc')->where('status', 1)->select();
$list_nav_more = Nav::where('type', 8)->order('sort asc')->where('status', 1)->where('type',11)->select();
View::assign('list_nav_more', $list_nav_more);
$top_posts = Post::where('is_top',1)->limit(8)->select();
$top_posts = Post::where('is_top',1)->limit(8)->where('type',3)->select();
$this->assign('top_posts',$top_posts);
}

View File

@@ -24,7 +24,7 @@ class Index extends Common
public function __blogIndex()
{
$list_category = Category::select();
$list_category = Category::where('type','blog_post')->select();
$this->assign('list_category',$list_category);
@@ -38,6 +38,8 @@ class Index extends Common
$model_list_post = Post::order('sort desc');
}
$model_list_post->where('type','blog_post');
$list_post = $model_list_post->paginate();
$this->assign('list_post',$list_post);
@@ -58,12 +60,12 @@ class Index extends Common
$sub_category = [];
if(!empty($this->request->param('category_id'))){
$sub_category = Category::where('pid',$this->request->param('category_id'))->select();
$sub_category = Category::where('pid',$this->request->param('category_id'))->where('type',3)->select();
if(empty($this->request->param('sub_category_id'))){
$categorys = [$this->request->param('category_id')];
$categorys = array_merge($categorys,array_column((array)Category::getListLevel($this->request->param('category_id')),'id'));
$categorys = array_merge($categorys,array_column((array)Category::getListLevel($this->request->param('category_id')),3));
$categorys_where = PostCategory::whereIn('category_id',$categorys);
@@ -77,6 +79,8 @@ class Index extends Common
$model_post = Post::where('status',1)->order('id desc');
}
$model_post->where('type',3);
$keywords = $this->request->param('keywords');
if(!empty($keywords)){