精華 帝國PHP系統(tǒng)列表頁,如何調(diào)用內(nèi)容頁的多張圖片?
帝國列表調(diào)用多張圖片的操作方法:
第一步:確保newstext字段可以在列表頁list.var中調(diào)用
假定你是新聞模型,假定你的newstext字段在主表中,假定你已經(jīng)在系統(tǒng)模型中勾選--- newstext字段的列表顯示,已確保newstext字段可以在列表頁list.var中調(diào)用。
第二步:添加自定義函數(shù)
以下函數(shù)到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 '';
}
第三步:列表模版勾選,使用程序代碼,列表內(nèi)容模板(list.var) (*)內(nèi)容可參考:
$myimg=getImgs($r[newstext]);
$listtemp=' ?<li> <DIV class="thumbImage" ><img src="http://www.viagraonlinego.com/662.html'.$myimg[0].'" /></div><a href="http://www.viagraonlinego.com/[!--titleurl--]" title="[!--oldtitle--]" target="_blank">[!--title--]</a></li> ?';
說明:
$myimg=getImgs($r[newstext]);
這里$myimg就是所有圖片的地址數(shù)組。
count($myimg) 就是圖片個數(shù),可以放到需要調(diào)用的地方。