主页 > 网站建设 > 建站知识 > DEDECMS首页和列表页调用单个图片集里的多张图片

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

POST TIME:2021-05-25 00:18

调用函数如下图:其中请修改一下数据库的表名字。否则会调用空白。

function Getimg($aid)
{
global $dsql;
$imgurls = '';
$row =$dsql->getone( "Select imgurls From `food_addpinpai` where aid='$aid' ");
$imgurls= $row['imgurls'];
preg_match_all("/{dede:img (.*){/dede:img/isU",$imgurls,$wordcount);
$count=count($wordcount[1]);
$dtp = new DedeTagParse();
$dtp->LoadSource($imgurls);
if(is_array($dtp->CTags))
{
$i=0;
foreach($dtp->CTags as $ctag)
{
if($i<$count){
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 href="'.$bigimg.'" title="'.$title.'" target=_blank><img src="'.$bigimg.'" alt="'.$title.'" ></a></li>';
$i++;
}
}
}
}
return $imglist;
}

调用方式:

[field:idfunction="Getimg(@me)"/]




收缩
  • 微信客服
  • 微信二维码
  • 电话咨询

  • 400-1100-266