Discuzx门户首页关键词和描述不登陆显示“门户”的解决方法
Discuz社区在后台设置好门户标题、关键字、描述,更新缓存,发现用户登录状态下,门户首页的关键字和描述正常显示;但在游客状态下不显示,在某工具中查看到的情况如下:现找到两种解决办法:(记得修改前备份源码)
方法一:
找到“ source/class/helper/helper_seo.php ”目录下的文件的38行~43行代买,如下:
if($descriptiontext && (isset($_G['makehtml']) || CURSCRIPT == 'forum' || IS_ROBOT || $_G['adminid'] == 1)) {
$seodescription = helper_seo::strreplace_strip_split($searchs, $replaces, $descriptiontext);
}
if($keywordstext && (isset($_G['makehtml']) || CURSCRIPT == 'forum' || IS_ROBOT || $_G['adminid'] == 1)) {
$seokeywords = helper_seo::strreplace_strip_split($searchs, $replaces, $keywordstext);
}
如果要和Discuz! 官网一样,在没有登录的情况下游客看到关键词和描述,登陆不显示
替换修改成如下代码:
if($descriptiontext && (isset($_G['makehtml']) || CURSCRIPT == 'forum' || CURSCRIPT == 'portal' || IS_ROBOT || $_G['adminid'] == 1)) {
$seodescription = helper_seo::strreplace_strip_split($searchs, $replaces, $descriptiontext);
}
if($keywordstext && (isset($_G['makehtml']) || CURSCRIPT == 'forum' || CURSCRIPT == 'portal' || IS_ROBOT || $_G['adminid'] == 1)) {
$seokeywords = helper_seo::strreplace_strip_split($searchs, $replaces, $keywordstext);
}
如果想要完全放开SEO设置给游客看,登不登陆都显示关键词和描述
替换修改成如下代码:
if($descriptiontext) {
$seodescription = helper_seo::strreplace_strip_split($searchs, $replaces, $descriptiontext);
}
if($keywordstext) {
$seokeywords = helper_seo::strreplace_strip_split($searchs, $replaces, $keywordstext);
}修改完成后,进入后台更新缓存,然后刷新门户首页,就可以正常显示了,完成。
方法二:
找到“template/default/common/header_common.htm ”目录下的文件的9行~10行代买,如下:
<meta name="keywords" content="{if !empty($metakeywords)}{echo dhtmlspecialchars($metakeywords)}{/if}" />
<meta name="description" content="{if !empty($metadescription)}{echo dhtmlspecialchars($metadescription)} {/if}{if empty($nobbname)},$_G['setting']['bbname']{/if}" />替换修改成如下代码:
<meta name="keywords" content="{if ''==strstr( $_G['setting']['seokeywords']['portal'])} $_G['setting']['seokeywords']['portal'] {/if}" />
<meta name="description" content="{if ''==strstr($_G['setting']['seodescription']['portal'])} $_G['setting']['seodescription']['portal'] {/if}/>修改完成后,进入后台更新缓存,然后刷新门户首页,就可以正常显示了,完成。
备注:方法二修改后,后台的“全局”->"SEO设置"->“门户”设置中的:例如站点名称bbname前台不解析,前台查看源码中的title,keywords,description还是显示bbname未解析成后台设置的站点名称,现未找到原因,标注下;
这个是什么意思
页:
[1]