DEDECMS织梦资讯详情页熊掌号改造代码

dedecms是常用的文章管理系统,今天小白分享是的资讯详情页面进行熊掌号改造的代码。
资讯页面的head部分代码:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>{dede:field.title/}-方圆模板</title>
<meta name="keywords" content="{dede:field.keywords/}" />
<meta name="description" content="{dede:field.description function='html2text(@me)'/}" />
<link rel="canonical" href="http://www.sdfymb.com{dede:field name='arcurl'/}" />
<script src="http://msite.baidu.com/sdk/c.js?appid=1634404368209099"></script>
<script type="application/ld+json">
    {
        "@context": "https://ziyuan.baidu.com/contexts/cambrian.jsonld",
        "@id": "http://www.sdfymb.com{dede:field name='arcurl'/}",
        "appid": "1634404368209099",
        "title": "{dede:field.title/}-方圆模板",
        "images": [{dede:field.body function=getbodypics(@me,3)/}],
        "pubDate": "{dede:field.pubdate function="MyDate('Y-m-d',@me)"/}T{dede:field.pubdate function="MyDate('H:i:s',@me)"/}"
    }
</script>
<link href="/skin/css/style.css" rel="stylesheet" type="text/css" />
</head>

然后修改/include/extend.func.php文件,在文件最下面添加:

// 获取文章主题图片
function getbodypics($string, $num)
    {
        preg_match_all("/<img([^>]*)\s*src=('|\")([^'\"]+)('|\")/",$string,$matches);
        $imgsrc_arr = array_unique($matches[3]);
        $count = count($imgsrc_arr);
        $i = 0;
		if($count>2){
        foreach($imgsrc_arr as $imgsrc)
        {
            if($i == $num) break;
			if($i == 2){$result .= "\"http://www.sdfymb.com$imgsrc\"";break;}
            $result .= "\"http://www.sdfymb.com$imgsrc\",";
            $i++;
        }
		}else{
		foreach($imgsrc_arr as $imgsrc)
        {
            if($i == 1) break;
            $result .= "\"http://www.sdfymb.com$imgsrc\"";
            $i++;
        }
		}
        return $result;
}

例如:页面http://www.sdfymb.com/news/709.html,其展现代码为:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>木质建筑圆模板优势及安装施工 柱子比钢模板支模更便捷-方圆模板</title>
<meta name="keywords" content="建筑圆模板" />
<meta name="description" content="木质建筑圆模板已经取代传统的 建筑圆模板 称为圆形建筑支模施工的优选,那么为什么选用方圆建筑模具加工生产的木质圆柱模板呢?其对比传统柱子钢模板有哪些优势呢?今天小编就为您介绍" />
<link rel="canonical" href="http://www.sdfymb.com/news/709.html" />
<script src="http://msite.baidu.com/sdk/c.js?appid=1634404368209099"></script>
<script type="application/ld+json">
    {
        "@context": "https://ziyuan.baidu.com/contexts/cambrian.jsonld",
        "@id": "http://www.sdfymb.com/news/709.html",
        "appid": "1634404368209099",
        "title": "木质建筑圆模板优势及安装施工 柱子比钢模板支模更便捷-方圆模板",
        "images": ["http://www.sdfymb.com/uploads/image/2019/1-191111095352945.jpg","http://www.sdfymb.com/uploads/image/2019/1-191111095411c2.jpg","http://www.sdfymb.com/uploads/image/2019/1-191111095432P2.jpg"],
        "pubDate": "2019-11-11T09:46:39"
    }
</script>
<link href="/skin/css/style.css" rel="stylesheet" type="text/css" />
</head>
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值