首页 > 网站 > 建站经验 > 正文

DEDECMS首页和列表页调用单个图片集里的多张图片

2024-04-25 20:51:31
字体:
来源:转载
供稿:网友

//**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)" /]
数字参数分别是图片宽度,图片高度,调用图片个数
发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表