技术文摘

帝国CMS列表页如何调用内容页多张图片

作者:雨祺   发表于:
浏览:83次    字数:745  原创
级别: 站长   总稿: 68 篇,  月稿: 0
假定你是新闻模型,假定你的newstext字段在主表中,假定你已经在系统模型中勾选--- newstext字段的列表显示,已确保newstext字段可以在列表页list.var中调用。
  1. <?php 
  2. function getImgs($content,$order='ALL'){ 
  3.         $pattern="/<img.*?src=['|"](.*?(?:[.gif|.jpg]))['|"].*?[/]?>/"
  4.         preg_match_all($pattern,$content,$match); 
  5.         if(isset($match[1])&&!empty($match[1])){ 
  6.                 if($order==='ALL'){ 
  7.                         return $match[1]; 
  8.                 } 
  9.                 if(is_numeric($order)&&isset($match[1][$order])){ 
  10.                         return $match[1][$order]; 
  11.                 } 
  12.         } 
  13.         return ''
  14. ?> 
复制到e/class/userfun.php 中
然后在列表模板勾选(list.var) ,调用
  1. $myimg=getImgs($r[newstext]); 
  2. $listtemp='  <li> <DIV class="thumbImage" ><img src="'.$myimg[0].'" /></div><a href="[!--titleurl--]" title="[!--oldtitle--]" target="_blank">[!--title--]</a></li>  '
图片等比例缩放css代码为:
  1. <style type="text/css"
  2. .thumbImage img{ 
  3. MAX-WIDTH: 100%!important;HEIGHT: auto!important;width:expression(this.width > 60 ? "60px" : this.width)!important; 
  4. .thumbImage {MARGIN: auto;WIDTH: 60px;} 
  5. *html.thumbImage img{ 
  6. width:expression(this.width>60&&this.width>this.height?45:auto); 
  7. height:expresion(this.height>45?45:auto); 
  8. </style> 

【审核人:站长】

收藏   加好友   生成海报   分享
点赞(0)
打赏
Tags: 图片 图集 帝国CMS

发布者资料

热门文章

技术文摘

查看更多技术文摘
首页
栏目
搜索
会员
投稿