From 2a71b4e65dfd559fd23102a2cb1c471b18618333 Mon Sep 17 00:00:00 2001 From: augushong Date: Thu, 26 May 2022 10:41:29 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96seo=E6=96=87=E7=AB=A0?= =?UTF-8?q?=E6=A0=87=E9=A2=98=E6=98=BE=E7=A4=BA=EF=BC=9B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/index/controller/Index.php | 19 ++++++++++++++++--- view/index/index/index.html | 4 ++-- 2 files changed, 18 insertions(+), 5 deletions(-) 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'/}