Home > Article > Backend Development > DEDECMS homepage calls multiple pictures in the picture collection, dedecms picture collection_PHP tutorial
First find the include/common.inc.php file and paste the following code into it (I posted the On my website, the details can be modified as needed):
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("/\}.+jpg/",$imgurls,$matches);//取出符合条件的 $new_arr=array_unique($matches[0]);//去除数组中重复的值 $pic_num1=" <dt><DIV class=tu_big><img id=imgInit class=zoom name=imgInit src=\"".substr($new_arr[0],2)."\" /></DIV></dt><dd><ul>"; foreach($new_arr as $key){ $pic_list.="<li><img onmouseover='pic_next(\"".substr($key,2)."\")' src=\"".substr($key,2)."\"' width=".$imgwith." height=".$imgheight." /></li>"; } $pic_end="</ul></dd>"; return $pic_num1.$pic_list.$pic_end;//返回结果 }
1. Calling method on dedecms website homepage and list page:
dede:arclist tag call and dede:list list call
[field:id function="Getimg(@me,80,80,7)" /]
80, 80 and 7 are respectively the width (omitted to be 110) and height (omitted to be 110) and the number of images to be displayed (omitted to be (0), indicating all images).
If there are multiple photo albums, add the category id of the photo album, as follows
[field:id typeid='' function="Getimg(@me,80,80,7)" /]
2. How to call multiple pictures in the picture collection within the dedecms article:
{dede:field.id function="Getimg(@me,80,80,7)" /}
If there are multiple photo albums, add the category id of the photo album, as follows
{dede:field.id typeid='' function="Getimg(@me,80,80,7)" /}
80, 80 and 7 are respectively the width (omitted to be 110) and height (omitted to be 110) and the number of images to be displayed (omitted to be (0), indicating all images).
The above is the entire content of this article. I hope it will be helpful to everyone to master dedecms.