方法一
2021-11-01更新
可以给每个栏目都加上seo标题,然后去设置标题样式,这种不涉及二开更适合。下图为参考样本,可以根据自己需求任意修改。
方法二
自从2.0.7版本开始后后台支持了自定义标题规则,然而发现这里的权限变成了最高,就是设置了规则后,再去单独给栏目设置seo标题就没效果了。这种情况我认为是不合理的,seo标题正常得最高级。
上面两张图即真实案例,第二张图给栏目设置seo标题无效了。那好吧,接下来讲解下如何让seo标题重回最高权限,即设置了seo标题,那就就会去替换掉组合标题里的栏目名称标题。
修改步骤
打开/apps/home/controller/IndexController.php
找到第189行private function getList($sort)
把以下代码
$content=str_replace('{pboot:pagetitle}',$this->config('list_title')?:($pagetitle.'-{pboot:sitetitle}-{pboot:sitesubtitle}'),$content);
替换成
$list_title=$this->config('list_title');if($pagetitle=="{sort:title}"){$list_title=str_replace("{sort:name}","{sort:title}",$list_title);}$content=str_replace('{pboot:pagetitle}',$list_title?:($pagetitle.'-{pboot:sitetitle}-{pboot:sitesubtitle}'),$content);
找到private function getAbout($sort)
把以下代码
$content=str_replace('{pboot:pagetitle}',$this->config('about_title')?:($pagetitle.'-{pboot:sitetitle}-{pboot:sitesubtitle}'),$content);
替换成
$about_title=$this->config('about_title');if($pagetitle=="{sort:title}"){$about_title=str_replace("{sort:name}","{sort:title}",$about_title);}$content=str_replace('{pboot:pagetitle}',$about_title?:($pagetitle.'-{pboot:sitetitle}-{pboot:sitesubtitle}'),$content);
修改完上面,去检查下页面发现标题正常了,到此结束,搞定!