网站建设 > SEO优化

帝国CMS百度熊掌号改造教程&方法

分类:SEO优化 发布时间:2021-11-19 07:32:08

摘要:帝国CMS如何&怎么进行百度熊掌号改造?百度熊掌号改造教程&方法&指南,熊掌号改造详细代码分享,帝国CMS改造出3张图。

帝国CMS如何改造百度熊掌号?

下面分享开拓族自用的代码,百度熊掌号详细改造代码如下:

内容模板代码(单图)

说明:页面顶部对内容图片做了判断,如果内容图片为空则赋值为LOGO图片。

此为1图效果代码

  1. <?php
  2. //当前内容标题图片
  3. $_titlepic = "https://www.kaituozu.com/d/file/img/logo.png";
  4. if (empty($navinfor[titlepic])) {$navinfor[titlepic] = $_titlepic;}
  5. ?>
  6. <!DOCTYPE html>
  7. <html lang="zh-CN">
  8. <head>
  9.     <meta charset="UTF-8">
  10.     <title>[!--pagetitle--]</title>
  11.     <meta name="description" content="[!--smalltext--]">
  12.     <link rel="canonical" href="[!--titleurl--]" />
  13.     <script src="//msite.baidu.com/sdk/c.js?appid=1601283669442885"></script>
  14.     <script type="application/ld+json">
  15.         {
  16.             "@context": "https://ziyuan.baidu.com/contexts/cambrian.jsonld",
  17.             "@id": "[!--titleurl--]",
  18.             "appid": "1601283669442885",
  19.             "title": "[!--pagetitle--]",
  20.             "images": [
  21.                 "<?=$navinfor[titlepic]?>",
  22.                 "",
  23.                 ""
  24.             ],
  25.             "description": "[!--smalltext--]",
  26.             "pubDate": "<?=date('Y-m-d',$navinfor[newstime])?>T<?=date('H:i:s',$navinfor[newstime])?>",
  27.             "isOriginal": "1"
  28.         }
  29.     </script>
  30. </head>
  31. <body>
  32.     <script>cambrian.render('body')</script>
  33. </body>
  34. </html>

内容模板代码(3图)

说明:变量$_img为内容所有图片数组,保证至少一张图(无图调用LOGO图片)。下为3图效果代码。

$_img[0][0]表示第一张图,其中$navinfor[titlepic]也表示第一张图;

$_img[0][1]表示第二张图;

$_img[0][2]表示第三张图。

  1. <?php
  2. //当前内容标题图片
  3. $_titlepic = "https://www.kaituozu.com/d/file/img/logo.png";
  4. if (empty($navinfor[titlepic])) {$navinfor[titlepic] = $_titlepic;}
  5. // 获取内容图片数组
  6. preg_match_all('/https:.*?(jpg|gif|png|bmp)/' ,$navinfor['newstext'], $_img);
  7. ?>
  8. <!DOCTYPE html>
  9. <html lang="zh-CN">
  10. <head>
  11.     <meta charset="UTF-8">
  12.     <title>[!--pagetitle--]</title>
  13.     <meta name="description" content="[!--smalltext--]">
  14.     <link rel="canonical" href="[!--titleurl--]" />
  15.     <script src="//msite.baidu.com/sdk/c.js?appid=1601283669442885"></script>
  16.     <script type="application/ld+json">
  17.         {
  18.             "@context": "https://ziyuan.baidu.com/contexts/cambrian.jsonld",
  19.             "@id": "[!--titleurl--]",
  20.             "appid": "1601283669442885",
  21.             "title": "[!--pagetitle--]",
  22.             "images": [
  23.                 "<?=$navinfor[titlepic]?>",
  24.                 "<?=$_img[0][1]?>",
  25.                 "<?=$_img[0][2]?>"
  26.             ],
  27.             "description": "[!--smalltext--]",
  28.             "pubDate": "<?=date('Y-m-d',$navinfor[newstime])?>T<?=date('H:i:s',$navinfor[newstime])?>",
  29.             "isOriginal": "1"
  30.         }
  31.     </script>
  32. </head>
  33. <body>
  34.     <script>cambrian.render('body')</script>
  35. </body>
  36. </html>

封面模板或列表模板代码

说明:开拓族栏目标题调用的别名,所以使用$_class数组储存该栏目数据。

$_class[bname]为别名

$_class[classpath]为栏目链接路径

$_class[fclast]为栏目最后修改时间

$_class[classimg]为栏目图片,并对栏目图片做了相应处理,如果栏目无图片则赋值为LOGO图片。

  1. <?php
  2. //当前栏目数组
  3. $_class=$empire->fetch1("select * from {$dbtbpre}enewsclass where classid='$GLOBALS[navclassid]'");
  4. //当前栏目图片
  5. $_classimg = "https://www.kaituozu.com/d/file/img/logo.png";
  6. if (empty($_class[classimg])) {$_class[classimg] = $_classimg;}
  7. ?>
  8. <!DOCTYPE html>
  9. <html lang="zh-CN">
  10. <head>
  11.     <meta charset="UTF-8">
  12.     <title><?=$_class[bname]?></title>
  13.     <meta name="description" content="[!--pagedes--]">
  14.     <link rel="canonical" href="[!--news.url--]<?=$_class[classpath]?>/" />
  15.     <script src="//msite.baidu.com/sdk/c.js?appid=1601283669442885"></script>
  16.     <script type="application/ld+json">
  17.         {
  18.             "@context": "https://ziyuan.baidu.com/contexts/cambrian.jsonld",
  19.             "@id": "[!--news.url--]<?=$_class[classpath]?>/",
  20.             "appid": "1601283669442885",
  21.             "title": "<?=$_class[bname]?>",
  22.             "images": [
  23.                 "<?=$_class[classimg]?>",
  24.                 "",
  25.                 ""
  26.             ],
  27.             "description": "[!--pagedes--]",
  28.             "pubDate": "<?=date('Y-m-d',$_class[fclast])?>T<?=date('H:i:s',$_class[fclast])?>",
  29.             "isOriginal": "1"
  30.         }
  31.     </script>
  32. </head>
  33. <body>
  34.     <script>cambrian.render('body')</script>
  35. </body>
  36. </html>

首页模板代码

  1. <!DOCTYPE html>
  2. <html lang="zh-CN">
  3. <head>
  4.     <meta charset="UTF-8">
  5.     <title>[!--pagetitle--]</title>
  6.     <meta name="description" content="[!--pagedes--]">
  7.     <link rel="canonical" href="[!--news.url--]" />
  8.     <script src="//msite.baidu.com/sdk/c.js?appid=1601283669442885"></script>
  9.     <script type="application/ld+json">
  10.         {
  11.             "@context": "https://ziyuan.baidu.com/contexts/cambrian.jsonld",
  12.             "@id": "[!--news.url--]",
  13.             "appid": "1601283669442885",
  14.             "title": "[!--pagetitle--]",
  15.             "images": [
  16.                 "https://www.kaituozu.com/d/file/img/logo.png",
  17.                 "",
  18.                 ""
  19.             ],
  20.             "description": "[!--pagedes--]",
  21.             "pubDate": "<?=date('Y-m-d')?>T<?=date('H:i:s')?>",
  22.             "isOriginal": "1"
  23.         }
  24.     </script>
  25. </head>
  26. <body>
  27.     <script>cambrian.render('body')</script>
  28. </body>
  29. </html>