您的位置:首页 > 其它

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

2018-03-16 13:33 453 查看
不改动官方核心文件,在自定义方法文件里加入个方法来实现

效果



include\extend.func.php 在最下面加入这个方法

function Getimgurls($aid,$num=4)
{
global $dsql;
$imgurls = $result = '';
$imgrow = $dsql->GetOne( "Select imgurls From `#@__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 .= "<li><div class='pic'><a title='{$row['text']}' href='{$row['imgsrc']}'><img src='{$row['imgsrc']}' mid='{$row['imgsrc']}' big='{$row['imgsrc']}' width='70' height='70'></a></div></li>";
}
$i++;
}
return $result;
}
}


<li><div class='pic'><a title='{$row['text']}' href='{$row['imgsrc']}'><img src='{$row['imgsrc']}' mid='{$row['imgsrc']}' big='{$row['imgsrc']}' width='70' height='70'></a></div></li>


改成你自己的,注意单双引号

前台模板 首页 或者 列表页 中调用

[field:id function=Getimgurls(@me,4)/]


数字
4
是调用几张图片
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  图集