Home >CMS Tutorial >DEDECMS >How to get multiple pictures in dedecms picture collection

How to get multiple pictures in dedecms picture collection

藏色散人
藏色散人Original
2019-12-20 09:44:482663browse

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 == &#39;li&#39;){ 
$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 template

The 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!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn