diff --git a/app/portal/data/portal.sql b/app/portal/data/portal.sql index ed78fd037b163f06c3ba89878fe94a8c76144e89..ba5b33af0a6f17c5e3fd86ba3f5f4ae8f3cb092b 100644 --- a/app/portal/data/portal.sql +++ b/app/portal/data/portal.sql @@ -11,6 +11,7 @@ CREATE TABLE IF NOT EXISTS `cmf_portal_category` ( `delete_time` int(10) UNSIGNED NOT NULL DEFAULT '0' COMMENT '删除时间', `list_order` float NOT NULL DEFAULT '10000' COMMENT '排序', `name` varchar(200) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '' COMMENT '分类名称', + `alias` varchar(128) NOT NULL DEFAULT '' COMMENT '分类别名', `description` varchar(255) NOT NULL DEFAULT '' COMMENT '分类描述', `path` varchar(255) NOT NULL DEFAULT '' COMMENT '分类层级关系路径', `seo_title` varchar(100) NOT NULL DEFAULT '', diff --git a/app/portal/service/ApiService.php b/app/portal/service/ApiService.php index 4e0f4b672a53f799fdeb6db13e25651c801c1496..410a9efc0bae4ebe2d454abbeb1471869c56f75d 100644 --- a/app/portal/service/ApiService.php +++ b/app/portal/service/ApiService.php @@ -419,11 +419,15 @@ class ApiService 'delete_time' => 0, ]; - return $portalCategoryModel + $temp = $portalCategoryModel ->where($where) ->where($paramWhere) - ->order($order) - ->select(); + ->order($order); + + if (!empty($param['ids'])) { + $temp->whereIn('id', $param['ids']); + } + return $temp->select(); } /** diff --git a/app/portal/taglib/Portal.php b/app/portal/taglib/Portal.php index 985a3c8cfd10c1e0b9e189fffdcb84868d78832f..355f507037216f61a892d6e3657fefbb45deda88 100644 --- a/app/portal/taglib/Portal.php +++ b/app/portal/taglib/Portal.php @@ -22,7 +22,8 @@ class Portal extends TagLib 'articles' => ['attr' => 'field,where,limit,order,page,relation,returnVarName,pageVarName,categoryIds', 'close' => 1],//非必须属性item 'tagarticles' => ['attr' => 'field,where,limit,order,page,relation,returnVarName,pageVarName,tagId', 'close' => 1],//非必须属性item 'breadcrumb' => ['attr' => 'cid', 'close' => 1],//非必须属性self - 'categories' => ['attr' => 'where,order', 'close' => 1],//非必须属性item + 'categories' => ['attr' => 'ids,where,order', 'close' => 1],//非必须属性item + 'category' => ['attr' => 'id', 'close' => 1],//非必须属性item 'subcategories' => ['attr' => 'categoryId', 'close' => 1],//非必须属性item 'allsubcategories' => ['attr' => 'categoryId', 'close' => 1],//非必须属性item ]; @@ -83,7 +84,7 @@ class Portal extends TagLib } } - if (strpos($tag['order'], '$') === 0) { + if (!empty($tag['order']) && strpos($tag['order'], '$') === 0) { $order = $tag['order']; $this->autoBuildVar($order); } else { @@ -236,7 +237,11 @@ parse; { $item = empty($tag['item']) ? 'vo' : $tag['item'];//循环变量名 $order = empty($tag['order']) ? '' : $tag['order']; + $ids = empty($tag['ids']) ? '""' : $tag['ids']; $returnVarName = 'portal_categories_data'; + if (strpos($ids, '$') === 0) { + $ids = $this->autoBuildVar($ids); + } $where = '""'; if (!empty($tag['where']) && strpos($tag['where'], '$') === 0) { $where = $tag['where']; @@ -247,6 +252,7 @@ parse; \${$returnVarName} = \app\portal\service\ApiService::categories([ 'where' => {$where}, 'order' => '{$order}', + 'ids' => {$ids} ]); ?> @@ -257,6 +263,29 @@ parse; return $parse; } + /** + * 文章分类详情标签 + * @param array $tag + * @param string $content + * @return string + */ + public function tagCategory($tag, $content) + { + $id = $tag['id'] ?: ''; + if (strpos($id, '$') === 0) { + $this->autoBuildVar($id); + } + $returnVarName = empty($tag['item']) ? 'portal_category' : $tag['item']; + + $parse = << +{$content} +parse; + return $parse; + } + /** * 文章子分类标签 */