Pursuing a dream dedecms article details the transformation of the code pages paws number:
<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>
But in weaving dreams of the original program does not exist getbodypics function, we need to modify the file: /include/extend.func.php,
finally add in the file:
// 获取文章主题图片
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;
}
This will be able to achieve a complete transformation paws number DEDECMS listing detail page!