discuz ! x3.4论坛熊掌号页面改造

1.打开source/module/forum/forum_viewthread.php

找到:

$page = max(1, $_G[‘page’]);

在上面添加以下代码:

$extrahead = $_G[‘siteurl’].’thread-‘.$_G[‘tid’].’-1-1.html’;

$article[‘gtime’] = date(“Y-m-d\TH:i:s”,$_G[‘forum_thread’][‘dateline’]);

2
2.打开source/module/portal/portal_view.php找到:a

$article[‘timestamp’] = $article[‘dateline’];

在上面添加以下代码:

$extrahead = $_G[‘siteurl’].’article-‘.$_G[‘id’].’-1.html’;

$article[‘gtime’] = date(“Y-m-d\TH:i:s”,$article[‘dateline’]);

继续查找:

$content[‘content’] = blog_bbcode($content[‘content’]);

下面添加:

if(!preg_match_all(“/(src)=([“|’]?)([^ “‘>]+)\\2/is”, $content[‘content’], $showimg));//官方号改造之内图数组化

foreach($showimg as $images) {

$showimg = $images;

}

3.打开模版文件夹下面的页头文件(包含移动端和PC端),一般是header和header_common,添加下面的JSON_LD和canonical标签

<!–熊掌号开始–>

<link rel=”canonical” href=”{$extrahead}”/>

<script type=”application/ld+json”>        {

“@context”: “https://ziyuan.baidu.com/contexts/cambrian.jsonld”,            “@id”: “{$extrahead}”,

“appid”: “如下图”,

“title”: “$navtitle”

“description”:”{$metadescription}”,

“pubDate”: “{$article[gtime]}”

}

</script><script src=”//msite.baidu.com/sdk/c.js?appid=如下图”></script>

<!–熊掌号结束–>