织梦dedecms调用图片集所有图片
function Getimgs($aid, $num = 0){
global $dsql;
$imgurls = '';
$row = $dsql -> getone("Select imgurls From`dede_addonimages` where aid='$aid'"); // 查询图片集sql by www.zuimoban.com
$imgurls = $row['imgurls'];
preg_match_all("/{dede:img ddimg='(.*)' text='(.*)' width(.*)}(.*){\/dede:img/isU", $imgurls, $wordcount); //调用图片路径和图片alt属性
$count = count($wordcount[4]);
if ($num > $count || $num == 0){
$num = $count;
}
for($i = 0;$i < $num;$i++){
$imglist .= '<li><span id="'.$i.'"><a href="'. trim($wordcount[4][$i]).'"><img src="'. trim($wordcount[4][$i]).'" alt="'.$wordcount[2][$i].'"/></a></span></li>'; //赋值到html标签
}
return $imglist;
}
第二步:在模板中用以下代码调用
{dede:field.id function="Getimgs(@me)" /}