Discuz社區在后台設置好門戶標題、關鍵字、描述,更新緩存,發現用戶登錄狀態下,門戶首頁的關鍵字和描述正常顯示;但在游客狀態下不顯示,在某工具中查看到的情況如下:
現找到兩種解決辦法:(記得修改前備份源碼)
方法一:找到“ source/class/helper/helper_seo.php ”目錄下的文件的38行~43行代買,如下:
替換修改成如下代碼:
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 ''==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未解析成后台設置的站點名稱,現未找到原因,標注下;