您现在的位置: 首页 > 帝国大学 > 模块插件

帝国cms模板改造加熊掌号推送代码包含首页列表页和内容页

来源:开发妹源码 发布时间:2020-03-06 20:11:53热度:
给帝国cms模板加熊掌号推送代码比如首页模板、列表页模板和内容页模板代码...
帝国cms模板加熊掌号推送代码比如首页模板、列表页模板和内容页模板代码。只需要复制对应的代码即可完成改造。

以下代码加入到head标签中。

首页代码:
  1. <link rel="canonical" href="[!--news.url--]" />
  2.     <script src="//msite.baidu.com/sdk/c.js?appid=自己的熊掌id"></script>
  3.     <script type="application/ld+json">
  4.         {
  5.             "@context": "https://ziyuan.baidu.com/contexts/cambrian.jsonld",
  6.             "@id": "[!--news.url--]",
  7.             "appid": "自己的熊掌id",
  8.             "title": "[!--pagetitle--]",
  9.             "images": [
  10.                 "https://网站的LOGO地址/logo.png",
  11.                 "",
  12.                 ""
  13.             ],
  14.             "description": "[!--pagedes--]",
  15.             "pubDate": "<?=date('Y-m-d')?>T<?=date('H:i:s')?>",
  16.             "isOriginal": "1"
  17.         }
  18.     </script>
列表页代码(多图的):
  1.    <link rel="canonical" href="[!--titleurl--]" />
  2.     <script src="//msite.baidu.com/sdk/c.js?appid=自己的熊掌id"></script>
  3.     <script type="application/ld+json">
  4.         {
  5.             "@context": "https://ziyuan.baidu.com/contexts/cambrian.jsonld",
  6.             "@id": "[!--titleurl--]",
  7.             "appid": "自己的熊掌id",
  8.             "title": "[!--pagetitle--]",
  9.             "images": [
  10.                 "<?=$navinfor[titlepic]?>",
  11.                 "<?=$_img[0][1]?>",
  12.                 "<?=$_img[0][2]?>"
  13.             ],
  14.             "description": "[!--smalltext--]",
  15.             "pubDate": "<?=date('Y-m-d',$navinfor[newstime])?>T<?=date('H:i:s',$navinfor[newstime])?>",
  16.             "isOriginal": "1"
  17.         }
  18.     </script>
下面这段代码放模板顶部用于提取图片:
 
  1. <?php
  2. $_class=$empire->fetch1("select * from {$dbtbpre}enewsclass where classid='$GLOBALS[navclassid]'");
  3. $_classimg = "https://img.kaituozu.com/img/logo.png";
  4. if (empty($_class[classimg])) {$_class[classimg] = $_classimg;}
  5. ?>
内容页单个图的代码:
  1.    
  2.   <link rel="canonical" href="[!--titleurl--]" />
  3.   <script src="//msite.baidu.com/sdk/c.js?appid=自己的熊掌id"></script>
  4. <script type="application/ld+json">
  5.         {
  6.             "@context": "https://ziyuan.baidu.com/contexts/cambrian.jsonld",
  7.             "@id": "[!--titleurl--]",
  8.             "appid": "自己的熊掌id",
  9.             "title": "[!--pagetitle--]",
  10.             "images": [
  11.                 "<?=$navinfor[titlepic]?>",
  12.                 "",
  13.                 ""
  14.             ],
  15.             "description": "[!--smalltext--]",
  16.             "pubDate": "<?=date('Y-m-d',$navinfor[newstime])?>T<?=date('H:i:s',$navinfor[newstime])?>",
  17.             "isOriginal": "1"
  18.         }
  19.     </script>
以下代码放到模板顶部用于提取图片,当没图片的时候用缩略图代替
 
  1. <?php
  2. $_titlepic = "https://logo图片地址/logo.png";
  3. if (empty($navinfor[titlepic])) {$navinfor[titlepic] = $_titlepic;}
  4. ?>
上面代码都是放在head标签里面,除了底下面声明的要放到模板顶部。

内容页可以根据自己实际使用情况在模板中加入。

 

本文地址:https://www.kaifamei.com/empirecms_md/89.html

    责任编辑:开发妹源码网