最新公告
  • 欢迎您光临站壳网,本站秉承服务宗旨 履行“站长”责任,销售只是起点 服务永无止境!立即加入我们
  • 织梦后台发布文章 织梦内容也调用

    织梦内容页做熊掌号主页展现和添加粉丝关注按钮,[转帖]织梦内容页做熊掌号有图片就输出三张,织梦内容页做熊掌号有图片就输出三张,下面小编来给大家介绍一下,一起来了解一下吧!

    织梦内容页做熊掌号,图片这一块,有文章内容图片就输出3张,没有就不输出,自动加逗号隔开,在 /include/extend.func.php 这个文件最下面加入一个函数

    /** *  文章内容提取图片(多张)自定义输出 *    织梦模板网  * @access    public * @param     string  $string  文档内容 * @param     string  $num  输出几张 * @return    string */if(!function_exists('getBodypics')){function getBodypics($string, $num){global $cfg_basehost;preg_match_all("/<img([^>]*)\s*src=('|\")([^'\"]+)('|\")/",$string,$matches);$imgsrc_arr = array_unique($matches[3]);$count = count($imgsrc_arr);$i = 0;$result = '';foreach($imgsrc_arr as $imgsrc){if($i == $num) break;$result .= ($result=='' ? '"'.$cfg_basehost.$imgsrc.'"' : ','.'"'.$cfg_basehost.$imgsrc.'"');$i++;}return $result;}}

     

    然后在织梦内容页模板在</head>前面加入

    <link rel="canonical" href="{dede:global.cfg_basehost/}{dede:field.id runphp=yes}$result=GetOneArchive(@me);@me=$result['arcurl'];{/dede:field.id}"><script src="//msite.baidu.com/sdk/c.js?appid=1608633444348086"></script><script type="application/ld+json">{"@context": "https://ziyuan.baidu.com/contexts/cambrian.jsonld","@id": "{dede:global.cfg_basehost/}{dede:field.id runphp=yes}$result=GetOneArchive(@me);@me=$result['arcurl'];{/dede:field.id}","appid": "1608633444348086","title": "{dede:field.title/}","images": [{dede:field.body function=getBodypics(@me,3)/}],"description": "{dede:field.description function=html2text(@me)/}","pubDate": "{dede:field.pubdate function="MyDate('Y-m-d\TH:i:s',@me)"/}"}</script>

    如果网站有独立手机端,把{dede:global.cfg_basehost/}这个改为手机域名,上面代码中那2个id 608633444348086改成你自己的熊掌号id

    以上就是织梦后台发布文章 织梦内容也调用的介绍,希望大家喜欢!

    更多教程关注FF推源码网。

    • 18775会员总数(位)
    • 5454资源总数(个)
    • 98本周发布(个)
    • 6 今日发布(个)
    • 1484稳定运行(天)

    提供最优质的资源集合

    立即查看 了解详情