dedecms织梦图集在首页列表页调用并且自定义输出几张的教程

2022-08-18

dedecms图集在首页列表页调用并且自定义输出几张图片,不改动官方核心文件。
打开 includeextend.func.php 在最下面加入这个方法
function Getimgurls($aid,$num=4) { global $dsql; $imgurls = $result = ''; $imgrow = $dsql->GetOne( "Select imgurls From `mydiy_addonimages` where aid='$aid' "); $imgurls = $imgrow['imgurls']; if($imgurls != '') { $dtp = new DedeTagParse(); $dtp->LoadSource($imgurls); $images = array(); if(is_array($dtp->CTags)) { foreach($dtp->CTags as $ctag) { if($ctag->GetName() == 'img') { $row = array(); $row['width'] = $ctag->GetAtt('width'); $row['height'] = $ctag->GetAtt('height'); $row['imgsrc'] = trim($ctag->GetInnerText()); $row['text'] = $ctag->GetAtt('text'); $images[] = $row; } } } $dtp->Clear(); $i = 0; foreach($images as $row) { if($i == $num) break; if($row['imgsrc'] != '') { $result .= "
  • "; } $i++; } return $result; } }
    注意

  • 这块根据自己页面的实际布局,自行修改Html标签
    前台模板 首页 或者 列表页 中调用
    [field:id function=Getimgurls(@me,5)/]
    数字5是调用本图集中的5张图

    非凡技术导航 优秀网址导航免费网站收录 网站地图

    本站收录的网站若侵害到您的利益,请联系我们删除处理

    Copyright ©2020 Guojiz V 5.5All Rights Reserved.

    备案号 )| 1735737677|