調(diào)用函數(shù)如下圖:其中請(qǐng)修改一下數(shù)據(jù)庫(kù)的表名字。否則會(huì)調(diào)用空白。
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;
}
調(diào)用方式:
[field:idfunction="Getimg(@me)"/]