下面分享开拓族自用的代码,百度熊掌号详细改造代码如下:
内容模板代码(单图)
说明:页面顶部对内容图片做了判断,如果内容图片为空则赋值为LOGO图片。
此为1图效果代码。
<?php //当前内容标题图片 $_titlepic = "https://www.1cn.cc/d/file/img/logo.png"; if (empty($navinfor[titlepic])) {$navinfor[titlepic] = $_titlepic;} ?> <!DOCTYPE html> <html lang="zh-CN"> <head> <meta charset="UTF-8"> <title>[!–pagetitle–]</title> <meta name="description" content="[!–smalltext–]"> <link rel="canonical" href="[!–titleurl–]" /> <script src="//msite.baidu.com/sdk/c.js?appid=1601283669442885"></script> <script type="application/ld+json"> { "@context": "https://ziyuan.baidu.com/contexts/cambrian.jsonld", "@id": "[!–titleurl–]", "appid": "1601283669442885", "title": "[!–pagetitle–]", "images": [ "<?=$navinfor[titlepic]?>", "", "" ], "description": "[!–smalltext–]", "pubDate": "<?=date('Y-m-d',$navinfor[newstime])?>T<?=date('H:i:s',$navinfor[newstime])?>", "isOriginal": "1" } </script> </head> <body> <script>cambrian.render('body')</script> </body> </html> |
内容模板代码(3图)
说明:变量$_img为内容所有图片数组,保证至少一张图(无图调用LOGO图片)。下为3图效果代码。
$_img[0][0]表示第一张图,其中$navinfor[titlepic]也表示第一张图;
$_img[0][1]表示第二张图;
$_img[0][2]表示第三张图。
<?php //当前内容标题图片 $_titlepic = "https://www.1cn.cc/d/file/img/logo.png"; if (empty($navinfor[titlepic])) {$navinfor[titlepic] = $_titlepic;} // 获取内容图片数组 preg_match_all('/https:.*?(jpg|gif|png|bmp)/' ,$navinfor['newstext'], $_img); ?> <!DOCTYPE html> <html lang="zh-CN"> <head> <meta charset="UTF-8"> <title>[!–pagetitle–]</title> <meta name="description" content="[!–smalltext–]"> <link rel="canonical" href="[!–titleurl–]" /> <script src="//msite.baidu.com/sdk/c.js?appid=1601283669442885"></script> <script type="application/ld+json"> { "@context": "https://ziyuan.baidu.com/contexts/cambrian.jsonld", "@id": "[!–titleurl–]", "appid": "1601283669442885", "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> </head> <body> <script>cambrian.render('body')</script> </body> </html> |
封面模板或列表模板代码
说明:开拓族栏目标题调用的别名,所以使用$_class数组储存该栏目数据。
$_class[bname]为别名
$_class[classpath]为栏目链接路径
$_class[fclast]为栏目最后修改时间
$_class[classimg]为栏目图片,并对栏目图片做了相应处理,如果栏目无图片则赋值为LOGO图片。
<?php //当前栏目数组 $_class=$empire->fetch1("select * from {$dbtbpre}enewsclass where classid='$GLOBALS[navclassid]'"); //当前栏目图片 $_classimg = "https://www.1cn.cc/d/file/img/logo.png"; if (empty($_class[classimg])) {$_class[classimg] = $_classimg;} ?> <!DOCTYPE html> <html lang="zh-CN"> <head> <meta charset="UTF-8"> <title><?=$_class[bname]?></title> <meta name="description" content="[!–pagedes–]"> <link rel="canonical" href="[!–news.url–]<?=$_class[classpath]?>/" /> <script src="//msite.baidu.com/sdk/c.js?appid=1601283669442885"></script> <script type="application/ld+json"> { "@context": "https://ziyuan.baidu.com/contexts/cambrian.jsonld", "@id": "[!–news.url–]<?=$_class[classpath]?>/", "appid": "1601283669442885", "title": "<?=$_class[bname]?>", "images": [ "<?=$_class[classimg]?>", "", "" ], "description": "[!–pagedes–]", "pubDate": "<?=date('Y-m-d',$_class[fclast])?>T<?=date('H:i:s',$_class[fclast])?>", "isOriginal": "1" } </script> </head> <body> <script>cambrian.render('body')</script> </body> </html> |
首页模板代码
<!DOCTYPE html> <html lang="zh-CN"> <head> <meta charset="UTF-8"> <title>[!–pagetitle–]</title> <meta name="description" content="[!–pagedes–]"> <link rel="canonical" href="[!–news.url–]" /> <script src="//msite.baidu.com/sdk/c.js?appid=1601283669442885"></script> <script type="application/ld+json"> { "@context": "https://ziyuan.baidu.com/contexts/cambrian.jsonld", "@id": "[!–news.url–]", "appid": "1601283669442885", "title": "[!–pagetitle–]", "images": [ "https://www.1cn.cc/d/file/img/logo.png", "", "" ], "description": "[!–pagedes–]", "pubDate": "<?=date('Y-m-d')?>T<?=date('H:i:s')?>", "isOriginal": "1" } </script> </head> <body> <script>cambrian.render('body')</script> </body> </html> |
声明:本站所有文章,如无特殊说明或标注,均为本站原创发布。任何个人或组织,在未征得本站同意时,禁止复制、盗用、采集、发布本站内容到任何网站、书籍等各类媒体平台。如若本站内容侵犯了原著者的合法权益,可联系我们进行处理。
评论(0)