首页站内杂志技术文摘
文章内容页

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

  • 作者:雨祺
  • 来源: 原创
  • 发表于2022-11-07 22:27:45
  • 被阅读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> 
    【审核人:站长】

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

        本文链接:https://www.meiweny.cn/zazhi/zhongwangjiaocheng/123.html

        赞一下

        深度阅读

        • 您也可以注册成为美文苑的作者,发表您的原创作品、分享您的心情!

        阅读记录

          关注美文苑