作者 lyh

gxai

... ... @@ -834,6 +834,16 @@ function ends_with($string, $suffix)
return substr($string, -strlen($suffix)) === $suffix;
}
function getCustomRouteMap($module_route,$route = '')
{
if($module_route == $route){
$resultRoute = $route;
}else{
$resultRoute = $module_route.'_catelog/'.$route;
}
return $resultRoute;
}
/**
* @remark :获取二级路由
* @name :getRouteMap
... ... @@ -841,11 +851,25 @@ function ends_with($string, $suffix)
* @method :post
* @time :2023/11/10 14:29
*/
function getRouteMap($source,$source_id){
function getRouteMap($source,$source_id,$is_upgrade = 0){
$route = '';
$routeMapModel = new RouteMap();
$info = $routeMapModel->read(['source'=>$source,'source_id'=>$source_id]);
if($info !== false){
if($is_upgrade == 1){
if($source == $routeMapModel::SOURCE_NEWS_CATE){
if($info['route'] != 'news'){
$route = $routeMapModel::PATH_NEWS_CATE.'/'.$info['route'];
}
}elseif ($source == $routeMapModel::SOURCE_BLOG_CATE){
if($info['route'] != 'blog'){
$route = $routeMapModel::PATH_BLOG_CATE.'/'.$info['route'];
}
}else{
$route = $info['route'];
}
return $route;
}
if(!empty($info['path'])){
if($info['path'] == 'blog'){
$info['path'] = $info['path'].'s';
... ...
... ... @@ -29,7 +29,7 @@ class BlogCategoryController extends BaseController
$template_id = $this->getTemplateId(BTemplate::SOURCE_BLOG,BTemplate::IS_LIST);
foreach ($lists as $k => $v){
$v['num'] = $blogModel->formatQuery(['category_id'=>['like','%,' . $v['id'] . ',%']])->count();
$v['url'] = $this->user['domain'] . getRouteMap(RouteMap::SOURCE_BLOG_CATE,$v['id']);
$v['url'] = $this->user['domain'] . getRouteMap(RouteMap::SOURCE_BLOG_CATE,$v['id'],$this->user['is_upgrade']);
$v['is_renovation'] = $this->getIsRenovation(BTemplate::SOURCE_BLOG,BTemplate::IS_LIST,$template_id,$v['id']);
$lists[$k] = $v;
}
... ...
... ... @@ -42,12 +42,7 @@ class CustomModuleCategoryController extends BaseController
$template_id = $this->getModuleTemplateId($this->param['module_id']);
foreach ($list as $k => $v){
$v['is_renovation'] = $this->getIsRenovation($v['module_id'],BTemplate::IS_LIST,$template_id,$v['id'],BTemplate::IS_CUSTOM);
$v['url'] = $this->user['domain'].$v['route'];
if($this->user['is_upgrade'] == 1){
if($v['route'] != $moduleInfo['route']){
$v['url'] = $this->user['domain'].$moduleInfo['route']."_catalog/".$v['route'];
}
}
$v['url'] = $this->user['domain'].getCustomRouteMap($moduleInfo['route'],$v['route']);
$list[$k] = $v;
}
}
... ...
... ... @@ -29,7 +29,7 @@ class NewsCategoryController extends BaseController
$template_id = $this->getTemplateId(BTemplate::SOURCE_BLOG,BTemplate::IS_LIST);
foreach ($lists as $k => $v){
$v['num'] = $newsModel->formatQuery(['category_id'=>['like','%,' . $v['id'] . ',%']])->count();
$v['url'] = $this->user['domain'].getRouteMap(RouteMap::SOURCE_NEWS_CATE,$v['id']);
$v['url'] = $this->user['domain'].getRouteMap(RouteMap::SOURCE_NEWS_CATE,$v['id'],$this->user['is_upgrade']);
$v['is_renovation'] = $this->getIsRenovation(BTemplate::SOURCE_NEWS,BTemplate::IS_LIST,$template_id,$v['id']);
$lists[$k] = $v;
}
... ...