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

时间:2023年08月26日

/

来源:网络

/

编辑:佚名

帝国CMS如何改造百度熊掌号?
下面分享78模板网自用的代码,百度熊掌号详细改造代码如下:
内容模板代码(单图)
说明:页面顶部对内容图片做了判断,如果内容图片为空则赋值为LOGO图片。
此为1图效果代码。
<?php
//当前内容标题图片
$_titlepic = "https://www.78moban.com/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.78moban.com/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.78moban.com/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.78moban.com/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>
猜你需要

豫ICP备2021026617号-1  豫公网安备:41172602000185   Copyright © 2021-2028 www.78moban.com/ All Rights Reserved

本站作品均来自互联网,转载目的在于传递更多信息,并不代表本站赞同其观点和对其真实性负责。如有侵犯您的版权,请联系 1565229909#qq.com(把#改成@),我们将立即处理。