zoukankan      html  css  js  c++  java
  • DEDECMS首页和列表页调用图片集多张图片的办法

    dede:arclist 标签调用和dede:list 列表调用  
     
    1 1
    2 [field:id function="Getimg(@me,80,80,7)" /]
     
    文章内页调用
     
    1 1
    2 {dede:field.id function="Getimg(@me,80,80,7)" /}
     
    80和80和7分别是要显示图片的宽度(省略为110)和高度(省略为110)和调用张数(省略为所有((0)),
     
    include/common.func.php增加一函数

    01 01
    02 function Getimg($aid,$imgwith=110,$imgheight=110,$num=0)
    03 02
    04 {
    05 03
    06 global $dsql;
    07 04
    08 $imgurls = '';
    09 05
    10 $row =$dsql->getone( "Select aid,imgurls From `dede_addonimages` where aid='$aid' ");
    11 06
    12 $id=$row['aid'];
    13 07
    14 $imgurls= $row['imgurls'];
    15 08
    16 $dtp = new DedeTagParse();
    17 09
    18 $dtp->LoadSource($imgurls);
    19 10
    20 if(is_array($dtp->CTags))
    21 11
    22 {
    23 12
    24     $i=0;
    25 13
    26     foreach($dtp->CTags as $ctag)
    27 14
    28          {
    29 15
    30             if($i<$num){
    31 16
    32                 if($ctag->GetName()=="img")
    33 17
    34                  {
    35 18
    36                      $bigimg = trim($ctag->GetInnerText());
    37 19
    38                      if($ctag->GetAtt('ddimg') != $bigimg && $ctag->GetAtt('ddimg')!='')
    39 20
    40                      {
    41 21
    42                             $litimg = $ctag->GetAtt('ddimg');
    43 22
    44                      }
    45 23
    46                      $title=$ctag->GetAtt('text');
    47 24
    48                      $imglist.='<li><a title="'.$title.'" href="/plus/view.php?aid='.$id.'"><img src="'.$bigimg.'" width="'.$imgwith.'" height="'.$imgheight.'" alt="'.$title.'"></a></li>';
    49 25
    50                      $i++;
    51 26
    52                  }
    53 27
    54             }
    55 28
    56         }
    57 29
    58     }
    59 30
    60 return $imglist;
    61 31
    62   
    63 32
    64 }
  • 相关阅读:
    ubuntu无法关机,卡死
    Ubuntu16.04安装8821CE 无线网卡无驱动
    百度Apollo学习(一)
    如何在Virtualbox中对Ubuntu系统根分区扩容
    Ubuntu下安装Google浏览器
    ubuntu下安装Firefox中国版解决Ubuntu与Windows下Firefox账号同步问题(已解决)
    ubuntu 下Visual Studio Code 安装
    百度Apollo搭建步骤(待更新)
    Ubuntu系统下常用的新建、删除、拷贝文件命令
    Ubuntu 16.04下docker ce的安装(待完善)
  • 原文地址:https://www.cnblogs.com/zqw111/p/13036596.html
Copyright © 2011-2022 走看看