调用函数如下图:其中请修改一下数据库的表名字。否则会调用空白。
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:id function="Getimg(@me)" /]