给帝国cms模板加熊掌号推送代码比如首页模板、列表页模板和内容页模板代码。只需要复制对应的代码即可完成改造。
以下代码加入到head标签中。
首页代码:
<link rel="canonical" href="[!--news.url--]" />
<script src="//msite.baidu.com/sdk/c.js?appid=自己的熊掌id"></script>
<script type="application/ld+json">
{
"@context": "https://ziyuan.baidu.com/contexts/cambrian.jsonld",
"@id": "[!--news.url--]",
"appid": "自己的熊掌id",
"title": "[!--pagetitle--]",
"images": [
"https://网站的LOGO地址/logo.png",
"",
""
],
"description": "[!--pagedes--]",
"pubDate": "<?=date('Y-m-d')?>T<?=date('H:i:s')?>",
"isOriginal": "1"
}
</script>
列表页代码(多图的):
<link rel="canonical" href="[!--titleurl--]" />
<script src="//msite.baidu.com/sdk/c.js?appid=自己的熊掌id"></script>
<script type="application/ld+json">
{
"@context": "https://ziyuan.baidu.com/contexts/cambrian.jsonld",
"@id": "[!--titleurl--]",
"appid": "自己的熊掌id",
"title": "[!--pagetitle--]",
"images": [
"<?=$navinfor[titlepic]?>",
"<?=$_img[0][1]?>",
"<?=$_img[0][2]?>"
],
"description": "[!--smalltext--]",
"pubDate": "<?=date('Y-m-d',$navinfor[newstime])?>T<?=date('H:i:s',$navinfor[newstime])?>",
"isOriginal": "1"
}
</script>
下面这段代码放模板顶部用于提取图片:
<?php
$_class=$empire->fetch1("select * from {$dbtbpre}enewsclass where classid='$GLOBALS[navclassid]'");
$_classimg = "https://img.kaituozu.com/img/logo.png";
if (empty($_class[classimg])) {$_class[classimg] = $_classimg;}
?>
内容页单个图的代码:
<link rel="canonical" href="[!--titleurl--]" />
<script src="//msite.baidu.com/sdk/c.js?appid=自己的熊掌id"></script>
<script type="application/ld+json">
{
"@context": "https://ziyuan.baidu.com/contexts/cambrian.jsonld",
"@id": "[!--titleurl--]",
"appid": "自己的熊掌id",
"title": "[!--pagetitle--]",
"images": [
"<?=$navinfor[titlepic]?>",
"",
""
],
"description": "[!--smalltext--]",
"pubDate": "<?=date('Y-m-d',$navinfor[newstime])?>T<?=date('H:i:s',$navinfor[newstime])?>",
"isOriginal": "1"
}
</script>
以下代码放到模板顶部用于提取图片,当没图片的时候用缩略图代替
<?php
$_titlepic = "https://logo图片地址/logo.png";
if (empty($navinfor[titlepic])) {$navinfor[titlepic] = $_titlepic;}
?>
上面代码都是放在head标签里面,除了底下面声明的要放到模板顶部。
内容页可以根据自己实际使用情况在模板中加入。