From 1aba74fac94db1b85df97f91e70018639af78ab3 Mon Sep 17 00:00:00 2001 From: filesite Date: Thu, 24 Apr 2025 23:26:25 +0800 Subject: [PATCH] improve breadcrumb get --- themes/tajian/controller/ListController.php | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/themes/tajian/controller/ListController.php b/themes/tajian/controller/ListController.php index 794a547..5c2f6cc 100644 --- a/themes/tajian/controller/ListController.php +++ b/themes/tajian/controller/ListController.php @@ -67,12 +67,16 @@ Class ListController extends SiteController { } //获取目录面包屑 + $breadcrumbs = $tagItem = array(); $tagId = $cateId = $this->get('id', ''); - $tagItem = $tags[$tagId]; - $breadcrumbs = $this->getBreadcrumbs($scanResults, $tagItem); //根据tag获取相关数据,并传给视图;调整视图兼容tag的数据结构 if (!empty($tags)) { + if (!empty($tagId) && !empty($tags[$tagId])) { + $tagItem = $tags[$tagId]; + $breadcrumbs = $this->getBreadcrumbs($tagItem); + } + foreach($tags as $id => $tag) { $scanResults[$id]['files'] = $this->getTagFiles($tag, $scanResults); } @@ -97,7 +101,7 @@ Class ListController extends SiteController { } //根据目录结构以及当前目录获取面包屑 - protected function getBreadcrumbs($menus, $tag) { + protected function getBreadcrumbs($tag) { $breads = array(); array_push($breads, [