请问帝国CMS列表页调用文章内容页多个图片方法
- 步骤:
- 确保
newstext
字段在主表中,并在系统模型中勾选newstext
字段的列表显示。 - 复制以下函数到
e/class/userfun.php
中:function getImgs($content, $order = 'ALL') { $content = stripslashes($content); $pattern = "/<img\b.*?\bsrc=([\''\"])(.*?)\\1.*?[\/]?>/i"; $i = 2; preg_match_all($pattern, $content, $match); if (isset($match[$i]) && !empty($match[$i])) { if ($order === 'ALL') { return $match[$i]; } if (is_numeric($order) && isset($match[$i][$order])) { return $match[$i][$order]; } } return ''; }
- 列表模版勾选,使用程序代码,列表内容模板(list.var) 示例:
$myimg = getImgs($r['newstext']); $listtemp = '<li> <DIV class="thumbImage" ><img src="' . $myimg[0] . '" /></div><a href="[!--titleurl--]" title="[!--oldtitle--]" target="_blank">[!--title--]</a></li>';
- 确保
- 说明:
$myimg
是所有图片的地址数组,count($myimg)
是图片个数。
更新时间:2025-04-11 00:40:43
上一篇:请问帝国CMS模板调用指定栏目的tag或当前栏目的tag
转载请注明原文链接:https://www.muzicopy.com/suibi/6224.html