From d607a4419fbf576c99d26dadc5a8b326eb331fd0 Mon Sep 17 00:00:00 2001 From: muzi_ys <1099438829@qq.com> Date: Sun, 24 Jul 2022 21:59:06 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=AD=A3nav=E6=8E=92=E5=BA=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/common/taglib/Ape.php | 67 ++++++++++++++++---------------- app/index/common.php | 3 +- app/index/controller/Article.php | 1 - app/index/controller/Page.php | 3 -- 4 files changed, 34 insertions(+), 40 deletions(-) diff --git a/app/common/taglib/Ape.php b/app/common/taglib/Ape.php index da4b9ce..43e803e 100644 --- a/app/common/taglib/Ape.php +++ b/app/common/taglib/Ape.php @@ -27,40 +27,6 @@ class Ape extends TagLib 'nav' => ['attr' => 'type,typeId,row,void,where,orderBy,display', 'close' => 1], ]; - /** - * 导航列表 - * type,栏目分类数据读取分类 - * typeId,导航列表分类,数字,字符串,或者变量 - */ - public function tagNav($tag, $content) - { - $type = $tag['type'] ?? 'son'; - $typeId = $tag['typeId'] ?? '$cid'; - $row = $tag['row'] ?? 100; - $void = $tag['void'] ?? 'field'; - $where = $tag['where'] ?? ''; - $orderBy = $tag['orderBy'] ?? 'sort asc'; - - $display = $tag['display'] ?? 1; - $display = $display == 1 ? 1 : 0; - //3中传参类型 - //1、栏目id,数字类型 - //2、多个栏目id,逗号隔开 - //3、变量 - //只有当多个栏目id时,才需要单引号加持。保证生成的为字符串 - if (strpos($typeId, ',')) { - $typeId = "'$typeId'"; - } - - $parse = ''; - $parse .= '{volist name="__LIST__" id="' . $void . '"}'; - $parse .= $content; - $parse .= '{/volist}'; - return $parse; - } - /** * 栏目列表 * type,栏目分类数据读取分类 @@ -372,4 +338,37 @@ class Ape extends TagLib return $parse; } + /** + * 导航列表 + * type,栏目分类数据读取分类 + * typeId,导航列表分类,数字,字符串,或者变量 + */ + public function tagNav($tag, $content) + { + $type = $tag['type'] ?? 'son'; + $typeId = $tag['typeId'] ?? '$cid'; + $row = $tag['row'] ?? 100; + $void = $tag['void'] ?? 'field'; + $where = $tag['where'] ?? ''; + $orderBy = $tag['orderBy'] ?? 'sort asc'; + + $display = $tag['display'] ?? 1; + $display = $display == 1 ? 1 : 0; + //3中传参类型 + //1、栏目id,数字类型 + //2、多个栏目id,逗号隔开 + //3、变量 + //只有当多个栏目id时,才需要单引号加持。保证生成的为字符串 + if (strpos($typeId, ',')) { + $typeId = "'$typeId'"; + } + + $parse = ''; + $parse .= '{volist name="__LIST__" id="' . $void . '"}'; + $parse .= $content; + $parse .= '{/volist}'; + return $parse; + } } \ No newline at end of file diff --git a/app/index/common.php b/app/index/common.php index ef32139..a6973c1 100644 --- a/app/index/common.php +++ b/app/index/common.php @@ -4,7 +4,6 @@ use app\common\constant\Data; use app\common\model\Comment; use app\common\model\Document; use app\common\model\DocumentCategory; -use app\common\model\DocumentCategoryContent; use app\common\model\Advert; use app\common\model\FriendLink; use app\common\model\Tag; @@ -1172,7 +1171,7 @@ function get_nav_list() //缓存文章菜单 $navList = cache(Data::DATA_NAV_LIST); if ($navList === null) { - $list = Nav::where('status', 1)->order('sort asc')->select()->toArray(); + $list = Nav::where('status', 1)->order('sort desc')->select()->toArray(); //转换,让id作为数组的键 $navList = []; foreach ($list as $item) { diff --git a/app/index/controller/Article.php b/app/index/controller/Article.php index b2c5693..d034d19 100644 --- a/app/index/controller/Article.php +++ b/app/index/controller/Article.php @@ -7,7 +7,6 @@ use app\common\constant\Data; use app\common\model\Comment as commentModel; use app\common\model\Document; use app\common\model\DocumentCategory; -use app\common\model\DocumentCategoryContent; use app\Request; use think\db\exception\DataNotFoundException; use think\db\exception\DbException; diff --git a/app/index/controller/Page.php b/app/index/controller/Page.php index 2a9ac96..e023408 100644 --- a/app/index/controller/Page.php +++ b/app/index/controller/Page.php @@ -6,9 +6,6 @@ use app\admin\extend\Util as Util; use app\common\constant\Data; use app\common\model\Comment as commentModel; use app\common\model\Document; -use app\common\model\DocumentCategory; -use app\common\model\DocumentCategoryContent; -use app\common\model\Tag as TagModel; use app\Request; use think\db\exception\DataNotFoundException; use think\db\exception\DbException;