From edf787ac08da72891b1164a728d094734db4a9da Mon Sep 17 00:00:00 2001 From: augushong Date: Thu, 26 May 2022 10:53:33 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E5=AD=90=E5=88=86=E7=B1=BB?= =?UTF-8?q?=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 | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/app/index/controller/Index.php b/app/index/controller/Index.php index 2e2be92..0ff05f3 100644 --- a/app/index/controller/Index.php +++ b/app/index/controller/Index.php @@ -42,7 +42,9 @@ class Index extends Common $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'))) { + + $sub_category_id = $this->request->param('sub_category_id'); + if (empty($sub_category_id)) { $categorys = [$category_id]; $categorys = array_merge($categorys, array_column((array)Category::getListLevel($category_id), 3)); @@ -51,8 +53,11 @@ 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'); + + $model_sub_category = Category::find($sub_category_id); + + $page_title .= "|{$model_sub_category->title}"; + $model_post = Post::hasWhere('categorys', ['category_id' => $sub_category_id])->where('status', 1)->order('id desc'); } } else {