1 | 后台创建一个image分类
2 | 建立文章,每个文章上传一个图片
3 | /include/extend.func.php 文件中 加入下面代码
function Getimgurls($aid,$num=4) { global $dsql; $imgurls = $result = ''; $imgrow = $dsql->GetOne( "Select imgurls From `dede_addonimages` where aid='$aid' "); $imgurls = $imgrow['imgurls']; if($imgurls != '') { $dtp = new DedeTagParse(); $dtp->LoadSource($imgurls); $images = array(); if(is_array($dtp->CTags)) { foreach($dtp->CTags as $ctag) { if($ctag->GetName() == 'img') { $row = array(); $row['width'] = $ctag->GetAtt('width'); $row['height'] = $ctag->GetAtt('height'); $row['imgsrc'] = trim($ctag->GetInnerText()); $row['text'] = $ctag->GetAtt('text'); $images[] = $row; } } } $dtp->Clear(); $i = 0; foreach($images as $row) { if($i == $num) break; if($row['imgsrc'] != '') { $result .= ""; } $i++; } return $result; } }
4 | 网页中调用
{dede:arclist row=4 typeid =13} [field:id function=Getimgurls(@me,4)/]{/dede:arclist}
后者
{dede:list pagesize='10'} [field:id function=Getimgurls(@me,4)/]{/dede:list}