Discus X 3 门户改造熊掌号网页教程

[复制链接]
查看2305 | 回复1 | 2019-9-18 08:46 | 显示全部楼层 |阅读模式
Discus X 3 门户改造熊掌号网页教程
DIscuz 改造熊掌号的难度主要来自 json_LD的处理上,接下来进行稍微的修改(影响后续升级)进行熊掌号的改造:
改造需要具备1个条件,就是手机站绑定了二级域名,如果没绑定二级域名的,请把教程里的
[url=http://$_G[setting][domain][app][mobile]http://$_G[setting][domain][app][mobile[/url]]
复制代码

[url=http://$_G[setting][domain][app][default]http://$_G[setting][domain][app][default[/url]]
复制代码

换成你自己的论坛域名
第一步打开:
/source/module/portal/portal_view.php
在75行左右的:
$content['content'] = blog_bbcode($content['content']);
复制代码


下面添加:
if(!preg_match_all("/(src)=([\"|']?)([^ \"'>]+)\\2/is", $content['content'], $showimg));//官方号改造之内图数组化
foreach($showimg as $images) {
$showimg = $images;
}
复制代码

第二步:
在243行左右的:
$article['timestamp'] = $article['dateline'];
复制代码

上面增加:
$article['gtime'] = date("Y-m-d\TH:i:s",$article['dateline']);//官方号改造之时间加T
复制代码

然后就完成了JSON_LD 里主要数据的改造

接下来就是改造模板了:
然后在 DIscuz 门户的手机端模板的 header 文件里写入:
添加canonical标签(必选):
<link rel="canonical" href=" http://$_G[setting][domain][app][mobile]/{$viewurl}"/>
复制代码

添加Json_LD数据(必选):
<script type="application/ld+json">
    {
        "@context": "https://ziyuan.baidu.com/contexts/cambrian.jsonld",
        "@id": "http://$_G[setting][domain][app][mobile]/{$viewurl}",
        "appid": "1539897736717695",
        "title": "{$article[title]}",
        "images": [
            "{if ($showimg[0])}http://$_G[setting][domain][app][default]/{$showimg[0]}{/if}"{if ($showimg[2])},"http://$_G[setting][domain][app][default]/{$showimg[1]}","http://$_G[setting][domain][app][default]/{$showimg[2]}"{/if}"
            ],
        "description": "{$article[summary]}",
        "pubDate": "{$article[gtime]}"
    }
</script>
复制代码


添加官方号ID声明(H5页面必选):
<script src="//msite.baidu.com/sdk/c.js?appid=你的 appid"></script>
然后在门户内容页 view.htm 里最下面的
<!--{template common/footer}-->
最后就是添加我们的 添加关注功能代码  代码放在文章内容即可,这里也是强烈推荐大家去添加的,添加之后用户看到文章之后可以通过关注代码关注我们的熊掌号,同时我们就可以通过运营中心将我们的内容推送给用户!并且可以更快的和用户去沟通!


蚂蚁 | 2019-9-18 08:58 | 显示全部楼层
自丢网真心不错,学习教程网。
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

UID
33
贡献
0
丢币
52
主题
47
回帖
5
注册时间
2018-9-26
最后登录
2019-12-6