-
DEDECMS首页和列表页调用单个图片集里的多张图片
-
function Getimg($aid,$imgwith=110,$imgheight=110,$num=0)
-
{
-
global $dsql;
-
$imgurls = '';
-
$row =$dsql->getone( "Select aid,imgurls From `js_addonimages` where aid='$aid' ");
-
$id=$row['aid'];
-
$imgurls= $row['imgurls'];
-
$dtp = new DedeTagParse();
-
$dtp->LoadSource($imgurls);
-
if(is_array($dtp->CTags))
-
{
-
$i=0;
-
foreach($dtp->CTags as $ctag)
-
{
-
if($i<$num){
-
if($ctag->GetName()=="img")
-
{
-
$bigimg = trim($ctag->GetInnerText());
-
if($ctag->GetAtt('ddimg') != $bigimg && $ctag->GetAtt('ddimg')!='')
-
{
-
$litimg = $ctag->GetAtt('ddimg');
-
}
-
$title=$ctag->GetAtt('text');
-
$imglist.='<li><a title="'.$title.'" href="/plus/view.php?aid='.$id.'"><img src="'.$bigimg.'" width="'.$imgwith.'" height="'.$imgheight.'" alt="'.$title.'"></a></li>';
-
$i++;
-
}
-
}
-
}
-
}
-
return $imglist;
-
-
}
调用方式:
-
[field:id function="Getimg(@me,119,90,5)" /]
数字参数分别是图片宽度,图片高度,调用图片个数
本文原地址:http://www.daimajiayuan.com/sitejs-18351-1.html