本帖最后由 神奇的路人甲 于 2017-11-14 20:49 编辑 1、熊掌号开通流程:《一步一步教你开通百度熊掌号》 2、和我学改造熊掌号之Discus X 3 门户改造《 和我学改造熊掌号之Discus X 3 门户改造》 3、WordPress改造熊掌号:【和我学改造熊掌号之WordPress】 4、PHPCMS改造熊掌号:【和我学改造熊掌号之PHPCMS改造】 5、帝国CMS改造熊掌号:【和我学改造熊掌号之帝国CMS改造】 6、织梦CMS改造熊掌号:【和我学改造熊掌号之织梦CMS改造】 这里感谢 沭阳网-仙神 提供的熊掌号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 里主要数据的改造 [size=18.6667px]接下来就是改造模板了:然后在 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}-->最后就是添加我们的 添加关注功能代码 代码放在文章内容即可,这里也是强烈推荐大家去添加的,添加之后用户看到文章之后可以通过关注代码关注我们的熊掌号,同时我们就可以通过运营中心将我们的内容推送给用户!并且可以更快的和用户去沟通! |