图集之列表/频道页等调用图集里的内容图片和注释

日前在一个项目中需要在图集列表点击每个图集的缩略图弹出当前的所有图片和注释,呈现那种画廊样式。

找了很多一直没找到合适的,若水印象网络工作室终于找到一个合适的并成功改写。

{dede:arclist typeid=5 orderby=’pubdate’ row=4}
[field:title/]

[field:id function=”Getimgs(@me,80,80,9)” /]

{/dede:arclist}

首先修改调用的部分

////循环输出多张图片
function Getimgs($aid, $imgwith = 300, $imgheight = 270, $num = 0, $style = ”){
global $dsql;
$imgurls = ”;
$row = $dsql -> getone(“Select imgurls From#@__addonimages18 where aid=’$aid'”); //
$imgurls = $row[‘imgurls’];

// preg_match(“‘alt=(.+)border'”, $imgurls,$array);
//preg_replace(“/\’/”,”, $array[1]);

 preg_match_all("/{dede:img (.*)}(.*){\/dede:img/isU", $imgurls, $wordcount);
 $textinfo = $wordcount[1];
 $count = count($wordcount[2]);
 if ($num > $count || $num == 0){
    $num = $count;
}

for($i = 0;$i < $num;$i++){
    if($style == 'li'){
        $imglist .= "<li><ahref=#" . $i . "><imgsrc=". trim($wordcount[2][$i]) . " width=" . $imgwith . " height=" . $imgheight . "></li></a>";
    }else{
        $textinfoe=$textinfo[$i];
        $textinfoee=explode(" ",$textinfoe);
        $imglist .= "<a href='" . trim($wordcount[2][$i]) . "' rel='works".$aid."' workstitle='".substr($textinfoee[1],6,-1)."'></a>";
    }
}
 return $imglist;
 }

分析以上的代码,最后一个if判断里我用的是else里的内容。
不要被我的代码迷惑了,那个A其实是一个特效,里边 trim($wordcount[2][$i]) 是用来获取图片地址,.substr($textinfoee[1],6,-1) 是用来获取注释,只要明白这两个的用途就可以构造自己想要的结果了,我的输出是这样的