Home > Article > CMS Tutorial > How to get multiple pictures in dedecms picture collection
dedecmsHow to get multiple pictures in the picture album?
dedecms implementation method of obtaining multiple pictures in a picture set (loop output)
Each case requires many pictures, and they are displayed with certain effects. The effect achieved by the calling method of DreamWeaver is to call multiple parameters at one time, and the displayed effect is not what I need. The following is the method of searching from Baidu. You can refer to it
Recommended learning: 梦Weavercms
The effect that needs to be achieved when making a website for a customer is that each case needs a lot of pictures and is displayed with a certain effect. However, I found that the effect achieved by DreamWeaver's own calling method was to call multiple parameters at once, and the effect displayed was not what I needed. I was very confused at the time. Later, I thought about it myself, but unfortunately I didn't succeed. Finally, I found the implementation method through Baidu search.
The implementation method has two steps:
1. Add the method in /include/common.func.php //Loop to output multiple pictures function
Code As follows:
function Getimgs($aid, $imgwith = 300, $imgheight = 270, $num = 0, $style = ''){ global $dsql; $imgurls = ''; $row = $dsql -> getone("Select imgurls From`dede_addonimages` where aid='$aid'"); // $imgurls = $row['imgurls']; preg_match_all("/{dede:img (.*)}(.*){\/dede:img/isU", $imgurls, $wordcount); $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{ $imglist .= "<img src= " . trim($wordcount[2][$i]) . " width=" . $imgwith . "height=" . $imgheight . ">"; } } return $imglist; }
2. Call the method {dede:field.id function="Getimgs(@me,400,400,10)" /}
in the templateThe above is the detailed content of How to get multiple pictures in dedecms picture collection. For more information, please follow other related articles on the PHP Chinese website!