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 }
  • 相关阅读:
    枚举转中文,通过反射方法与描述的方式获取
    PropertyGrid 重难点总结
    Image与Bitmap的区别及相互转换
    A generic error occurred in GDI+的解决方案
    C# 鼠标穿透窗体与恢复
    struts2 validate验证
    Struts2 | struts.xml文件中使用method属性和通配符简化action标签和Action处理类的编写
    struts2中struts.xml和web.xml文件解析及工作原理
    Struts2中Struts.xml的作用
    <a>标签是什么意思 怎么使用?
  • 原文地址:https://www.cnblogs.com/zqw111/p/13036596.html
Copyright © 2011-2022 走看看