织梦列表页调用图集多个图片完美解决方法
织梦列表页调用图集多个图片完美解决方法
网上有很多解决方法,但都有问题
元素模板为您解答
{dede:list pagesize=’10’}
<div class=” leftbox wow fadeInLeft”>
<div class=”table”>
[field:field:id function=”Getimg(@me,80,80,7)” /]
</div>
</div>
<div class=” rightbox wow fadeInRight”>
<div class=”hd2″>
<h2>[field:title/]</h2>
</div>
</div>
{/dede:list}
function Getimg($aid,$imgwith,$imgheight)
{
global $dsql;
$imgurls = ”;
$row =$dsql->getone( “select imgurls from dede_addonimages where aid=’$aid’ “);
$imgurls= $row[‘imgurls’];//获取字段数据
preg_match_all(“/}.+(?:gif|jpeg|jpg|png)/”,$imgurls,$matches);//取出符合条件的
$new_arr=array_unique($matches[0]);//去除数组中重复的值
foreach($new_arr as $key){
$pic_list.=”<div class=’swiper-slide’><img src='”.substr($key,2).”‘ /></div>”;
}
$pic_num1=”<div class=’item item2′><div class=’swiper-container swiper-content’><div id=’swiper2′ class=’swiper-wrapper’>”.$pic_list.” </div><div class=’swiper-pagination hidden-sm hidden-md hidden-lg’></div></div> </div><div class=’item item1 hidden-xs’><div class=’swiper-container swiper-thumbs’><div id=’swiper1′ class=’swiper-wrapper’>”.$pic_list.”</div> </div></div>”;
return $pic_num1;//返回结果
}