diff --git a/app/index/controller/Index.php b/app/index/controller/Index.php index 6d63b1d..2e2be92 100644 --- a/app/index/controller/Index.php +++ b/app/index/controller/Index.php @@ -28,6 +28,8 @@ class Index extends Common return $content; } + $page_title = '全部文章'; + // $sub_category = []; $current_category = []; @@ -35,8 +37,11 @@ class Index extends Common $category_id = $this->request->param('category_id'); if (!empty($category_id)) { - $sub_category = Category::where('pid', $category_id)->where('type', 3)->order('sort asc')->select(); $current_category = Category::find($category_id); + + $page_title = $current_category->title; + + $sub_category = Category::where('pid', $category_id)->where('type', 3)->order('sort asc')->select(); if (empty($this->request->param('sub_category_id'))) { $categorys = [$category_id]; @@ -46,6 +51,7 @@ class Index extends Common $model_post = Post::hasWhere('categorys', $categorys_where)->where('status', 1)->order('id desc'); } else { + $page_title .= "|{$sub_category->title}"; $model_post = Post::hasWhere('categorys', ['category_id' => $this->request->param('sub_category_id')])->where('status', 1)->order('id desc'); } } else { @@ -58,16 +64,22 @@ class Index extends Common $keywords = $this->request->param('keywords'); if (!empty($keywords)) { - $model_post->whereLike('title|desc', "%$keywords%"); + $model_post->whereLike('title|desc|content', "%$keywords%"); + + $page_title .= "|{$keywords}"; } + $page = $this->request->param('page', 1); + + $page_title .= "|第{$page}页"; $list_post = $model_post->paginate([ 'url' => 'Index/index', 'query' => [ 'category_id' => $this->request->param('category_id'), 'sub_category_id' => $this->request->param('sub_category_id'), - 'page' => $this->request->param('page'), + 'page' => $page, + 'keywords' => $keywords ], 'list_rows' => 10 ]); @@ -76,6 +88,7 @@ class Index extends Common View::assign('sub_category', $sub_category); View::assign('list_post', $list_post); + View::assign('page_title', $page_title); $content = View::fetch(); diff --git a/view/index/index/index.html b/view/index/index/index.html index 42824f5..5edcf45 100644 --- a/view/index/index/index.html +++ b/view/index/index/index.html @@ -4,9 +4,9 @@ - {$current_category.title|default='全部文章'}|{:get_system_config('site_name')} + {$page_title}|{:get_system_config('site_name')} - + {include file='common/_require'/}