修正nav排序

This commit is contained in:
muzi_ys 2022-07-24 21:59:06 +08:00
parent 7bb3c17598
commit d607a4419f
4 changed files with 34 additions and 40 deletions

View File

@ -27,40 +27,6 @@ class Ape extends TagLib
'nav' => ['attr' => 'type,typeId,row,void,where,orderBy,display', 'close' => 1], '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 = '<?php ';
$parse .= '$__LIST__ = ' . "tpl_get_nav(\"$type\",$typeId,$row,\"$where\",\"$orderBy\",$display);";
$parse .= ' ?>';
$parse .= '{volist name="__LIST__" id="' . $void . '"}';
$parse .= $content;
$parse .= '{/volist}';
return $parse;
}
/** /**
* 栏目列表 * 栏目列表
* type,栏目分类数据读取分类 * type,栏目分类数据读取分类
@ -372,4 +338,37 @@ class Ape extends TagLib
return $parse; 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 = '<?php ';
$parse .= '$__LIST__ = ' . "tpl_get_nav(\"$type\",$typeId,$row,\"$where\",\"$orderBy\",$display);";
$parse .= ' ?>';
$parse .= '{volist name="__LIST__" id="' . $void . '"}';
$parse .= $content;
$parse .= '{/volist}';
return $parse;
}
} }

View File

@ -4,7 +4,6 @@ use app\common\constant\Data;
use app\common\model\Comment; use app\common\model\Comment;
use app\common\model\Document; use app\common\model\Document;
use app\common\model\DocumentCategory; use app\common\model\DocumentCategory;
use app\common\model\DocumentCategoryContent;
use app\common\model\Advert; use app\common\model\Advert;
use app\common\model\FriendLink; use app\common\model\FriendLink;
use app\common\model\Tag; use app\common\model\Tag;
@ -1172,7 +1171,7 @@ function get_nav_list()
//缓存文章菜单 //缓存文章菜单
$navList = cache(Data::DATA_NAV_LIST); $navList = cache(Data::DATA_NAV_LIST);
if ($navList === null) { if ($navList === null) {
$list = Nav::where('status', 1)->order('sort asc')->select()->toArray(); $list = Nav::where('status', 1)->order('sort desc')->select()->toArray();
//转换让id作为数组的键 //转换让id作为数组的键
$navList = []; $navList = [];
foreach ($list as $item) { foreach ($list as $item) {

View File

@ -7,7 +7,6 @@ use app\common\constant\Data;
use app\common\model\Comment as commentModel; use app\common\model\Comment as commentModel;
use app\common\model\Document; use app\common\model\Document;
use app\common\model\DocumentCategory; use app\common\model\DocumentCategory;
use app\common\model\DocumentCategoryContent;
use app\Request; use app\Request;
use think\db\exception\DataNotFoundException; use think\db\exception\DataNotFoundException;
use think\db\exception\DbException; use think\db\exception\DbException;

View File

@ -6,9 +6,6 @@ use app\admin\extend\Util as Util;
use app\common\constant\Data; use app\common\constant\Data;
use app\common\model\Comment as commentModel; use app\common\model\Comment as commentModel;
use app\common\model\Document; 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 app\Request;
use think\db\exception\DataNotFoundException; use think\db\exception\DataNotFoundException;
use think\db\exception\DbException; use think\db\exception\DbException;