BLOG記事用論壇

 找回密碼
 註冊
搜索
熱搜:
查看: 3354|回復: 0

Discuz 論壇的$metadescription 修復

[複製鏈接]
發表於 2018-3-28 18:28:08 | 顯示全部樓層 |閱讀模式

使用Discuz X3.4版本後
發現meta中的metadescription有個大問題,
就是只有論壇創始人能看見metadescription
其他人呢?全部看不到
其他人只看的見文章名稱,無法顯示內容。
這無疑對論壇SEO優惠有很大影響。

這問題困擾了我很久,
最後決定自己解決。
為了這個我下載Fileseak去搜尋php檔案內的字。


先搜尋$metadescription後發現程式碼都正常
不過發現這也跟$summary變數有關,
  1. if(!$metadescription) {
  2.         $metadescription = $summary.' '.strip_tags($_G['forum_thread']['subject']);
  3. }
複製代碼


改搜$summary後,發現有一行字很怪,
檔案source\module\forum\forum_viewthread.php
  1. if(!$_G['forum_thread']['price'] && (IS_ROBOT || $_G['adminid'] == 1)) $summary = str_replace(array("\r", "\n"), '', messagecutstr(strip_tags($post['message']), 160));
複製代碼


發現這是一個很大的問題,
只有IS_ROBOT 或是adminid為 1的人才能看到$summary
也就是$metadescription
因此我決定將它刪掉或註解ˋ掉
註解ˋ掉變成
  1. //if(!$_G['forum_thread']['price'] && (IS_ROBOT || $_G['adminid'] == 1))
  2.                         $summary = str_replace(array("\r", "\n"), '', messagecutstr(strip_tags($post['message']), 160));
複製代碼

記得後面要換行,不然會連$summary一起註解,

刪掉就是直接變成
  1. $summary = str_replace(array("\r", "\n"), '', messagecutstr(strip_tags($post['message']), 160));
複製代碼

之後......果然解決了

您需要登錄後才可以回帖 登錄 | 註冊

本版積分規則

手機版|Archiver|綜合討論區

GMT+8, 2026-8-19 20:46 , Processed in 0.144438 second(s), 9 queries , File On.

Powered by Discuz! X3.4

Copyright © 2001-2020, Tencent Cloud.

快速回復 返回頂部 返回列表