From a907263a0d17d22b40f94207631bade2813df7ca Mon Sep 17 00:00:00 2001 From: ouzhiqiang <835402500@qq.com> Date: Fri, 19 Sep 2025 14:31:56 +0800 Subject: [PATCH 1/6] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=88=86=E7=B1=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/index/controller/TopicNas.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/app/index/controller/TopicNas.php b/app/index/controller/TopicNas.php index c4315039..e565cebd 100644 --- a/app/index/controller/TopicNas.php +++ b/app/index/controller/TopicNas.php @@ -192,6 +192,8 @@ class TopicNas extends Common { // 获取文章分类及文章数据 $parent = ArticleCategoryModel::uniqueLabel('CATEGORY_681182e0a4529')->language($this->lang_id)->value('id'); + $parent_two = ArticleCategoryModel::parent($parent)->language($this->lang_id)->column('id');//二级分类id + array_push($parent_two,$parent); $article_categorys = ArticleCategoryModel::with(['article' => function($query) { $query->field(['id', 'title', 'category_id']) ->order(['sort' => 'asc', 'id' => 'desc']) @@ -203,7 +205,8 @@ class TopicNas extends Common 'icon' ]) ->language($this->lang_id) - ->parent($parent) +// ->parent($parent) + ->parentChild($parent_two) ->isShow(true) ->order(['sort' => 'asc', 'id' => 'desc']) ->select(); From 2d4ad60c0f77f34122fa596b8ec41b81fd36a08f Mon Sep 17 00:00:00 2001 From: ouzhiqiang <835402500@qq.com> Date: Fri, 19 Sep 2025 14:36:08 +0800 Subject: [PATCH 2/6] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=88=86=E7=B1=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/index/controller/TopicNas.php | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/app/index/controller/TopicNas.php b/app/index/controller/TopicNas.php index e565cebd..e41128a6 100644 --- a/app/index/controller/TopicNas.php +++ b/app/index/controller/TopicNas.php @@ -210,6 +210,27 @@ class TopicNas extends Common ->isShow(true) ->order(['sort' => 'asc', 'id' => 'desc']) ->select(); + //查询三级分类 + $article_categorys_new = []; + $article_categorys_two = []; + dump($article_categorys->toArray());exit; + if (!$article_categorys->isEmpty()) { + foreach ($article_categorys->toArray() as $kk=>$vv) { + if ( $parent == $vv['pid'] ) { + $vv['child'] = ''; + array_push($article_categorys_new,$vv); + } else { + $article_categorys_two[$vv['pid']][] = $vv; + } + } + if ( !empty($article_categorys_two) ) { + foreach ($article_categorys_new as &$vvv) { + $vvv['child'] = isset($article_categorys_two[$vvv['id']])?$article_categorys_two[$vvv['id']]:''; + } + } + } + + View::assign('article_categorys', $article_categorys); $contacts = []; From 88daf237733879940f399c714e6a2eb11041fc04 Mon Sep 17 00:00:00 2001 From: ouzhiqiang <835402500@qq.com> Date: Fri, 19 Sep 2025 14:47:05 +0800 Subject: [PATCH 3/6] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=88=86=E7=B1=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/index/controller/TopicNas.php | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/app/index/controller/TopicNas.php b/app/index/controller/TopicNas.php index e41128a6..3051c7f1 100644 --- a/app/index/controller/TopicNas.php +++ b/app/index/controller/TopicNas.php @@ -213,11 +213,10 @@ class TopicNas extends Common //查询三级分类 $article_categorys_new = []; $article_categorys_two = []; - dump($article_categorys->toArray());exit; +// dump($article_categorys->toArray());exit; if (!$article_categorys->isEmpty()) { foreach ($article_categorys->toArray() as $kk=>$vv) { if ( $parent == $vv['pid'] ) { - $vv['child'] = ''; array_push($article_categorys_new,$vv); } else { $article_categorys_two[$vv['pid']][] = $vv; @@ -225,13 +224,21 @@ class TopicNas extends Common } if ( !empty($article_categorys_two) ) { foreach ($article_categorys_new as &$vvv) { - $vvv['child'] = isset($article_categorys_two[$vvv['id']])?$article_categorys_two[$vvv['id']]:''; + $articles = $vvv['article']; + if ( isset($article_categorys_two[$vvv['id']]) ) { + foreach ($article_categorys_two[$vvv['id']] as $k=>$v) { + $articles = array_merge($articles,$v['article']); + } + + } + $vvv['article'] = $articles; } } } - View::assign('article_categorys', $article_categorys); + View::assign('article_categorys', $article_categorys_new); +// View::assign('article_categorys', $article_categorys); $contacts = []; // 获取banner数据 From 9fff29a7027ecc364fea56511369bebde248aa84 Mon Sep 17 00:00:00 2001 From: ouzhiqiang <835402500@qq.com> Date: Fri, 19 Sep 2025 14:48:10 +0800 Subject: [PATCH 4/6] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=88=86=E7=B1=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/index/controller/TopicNas.php | 1 + 1 file changed, 1 insertion(+) diff --git a/app/index/controller/TopicNas.php b/app/index/controller/TopicNas.php index 3051c7f1..6471e76c 100644 --- a/app/index/controller/TopicNas.php +++ b/app/index/controller/TopicNas.php @@ -201,6 +201,7 @@ class TopicNas extends Common }]) ->field([ 'id', + 'pid', 'name', 'icon' ]) From 69628a0c6c3eede6a48b265b4fbf396f6fd0b2a7 Mon Sep 17 00:00:00 2001 From: ouzhiqiang <835402500@qq.com> Date: Fri, 19 Sep 2025 14:59:45 +0800 Subject: [PATCH 5/6] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=88=86=E7=B1=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/index/controller/TopicNas.php | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/app/index/controller/TopicNas.php b/app/index/controller/TopicNas.php index 6471e76c..ad52c5fc 100644 --- a/app/index/controller/TopicNas.php +++ b/app/index/controller/TopicNas.php @@ -227,10 +227,13 @@ class TopicNas extends Common foreach ($article_categorys_new as &$vvv) { $articles = $vvv['article']; if ( isset($article_categorys_two[$vvv['id']]) ) { - foreach ($article_categorys_two[$vvv['id']] as $k=>$v) { - $articles = array_merge($articles,$v['article']); + foreach ($article_categorys_two[$vvv['id']] as $v) { + foreach ($v['article'] as $av) { + if ( count($articles) < 3 ) { + array_push($articles,$av); + } + } } - } $vvv['article'] = $articles; } From 2c17677e03f50317f853433260f0a8d33b04af0f Mon Sep 17 00:00:00 2001 From: ouzhiqiang <835402500@qq.com> Date: Fri, 19 Sep 2025 15:14:55 +0800 Subject: [PATCH 6/6] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=88=86=E7=B1=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/index/view/pc/topic_nas/help.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/index/view/pc/topic_nas/help.html b/app/index/view/pc/topic_nas/help.html index 7773f437..5c448443 100644 --- a/app/index/view/pc/topic_nas/help.html +++ b/app/index/view/pc/topic_nas/help.html @@ -32,7 +32,7 @@