Skip to main content
 Web开发网 » 站长学院 » 织梦教程

织梦dedecms图集productimagelist标签调用和常见问题汇总

2020年09月12日10940百度已收录

织梦dedecms图集调用标签({dede:productimagelist})在制作图片站时候是经常会用到的,下面小编就此标签的使用方法和常用调用问题进行汇总,希望能够帮到使用此标签的朋友。下面我们先看下此标签的使用:

 

标签名称:productimagelist

标记简介:无

功能说明:用于获取产品图片集

适用范围:内容标记

基本语法:

 

<span style="font-family:tahoma,geneva,sans-serif;"><span style="font-size:14px;">{dede:productimagelist}

<a href="[field:imgsrc/]" title="[field:text/]"><img src="[field:imgsrc/]" width="120" height="90" /></a>

{/dede:productimagelist}</span></span>

 

参数说明:

底层模板字段:

imgsrc :图片路径

text :文字描述

注释:

本标签可用于调用自定义字段类型为imgurls的字段。

 

 

1.织梦dedecms给productimagelist图集标签添加数字编号自增的方法

 

打开 /include/taglib/productimagelist.lib.php 文件

找到:

 

<span style="font-family:tahoma,geneva,sans-serif;"><span style="font-size:14px;">$ctp->LoadSource($innerText);</span></span>

 

在此代码下边添加如下代码:

 

<span style="font-family:tahoma,geneva,sans-serif;"><span style="font-size:14px;">$GLOBALS['autoindex'] = 0;</span></span>

 

找到:

 

<span style="font-family:tahoma,geneva,sans-serif;"><span style="font-size:14px;">$revalue .= $ctp->GetResult();</span></span>

 

在此代码下边添加如下代码

 

<span style="font-family:tahoma,geneva,sans-serif;"><span style="font-size:14px;">$GLOBALS['autoindex']++;</span></span>

 

调用代码:

 

<span style="font-family:tahoma,geneva,sans-serif;"><span style="font-size:14px;">[field:global name=autoindex/]</span></span>

 

示例:

 

<span style="font-family:tahoma,geneva,sans-serif;"><span style="font-size:14px;">{dede:productimagelist}

<span id="[field:global name=autoindex/]"><img src="[field:imgsrc/]" alt="www.genban.org" width="200" height="300" /></span>

{/dede:productimagelist}

</span></span>

 

输出html代码:

<span id="0"><img src="1.jpg" alt="www.genban.org" width="200" height="300" /></span>

<span id="1"><img src="2.jpg" alt="www.genban.org" width="200" height="300" /></span>

<span id="2"><img src="3.jpg" alt="www.genban.org" width="200" height="300" /></span>

 

2.织梦dedecms图集标签productimagelist调用图片顺序的修改方法

 

织梦dedecms图集标签{dede:productimagelist}默认调用的图片顺序是旧图片在前,新图片在后,如何更改图片顺序,让新图片在前,旧图片在后

 

打开 /include/taglib/productimagelist.lib.php 文件

找到:

 

<span style="font-family:tahoma,geneva,sans-serif;"><span style="font-size:14px;">foreach($dtp->CTags as $ctag)

{

if($ctag->GetName()=="img")</span></span>

 

修改为:

 

 

就这样简单的一步修改即可

 

3.织梦dedecms的{dede:productimagelist}标签调用图集标题title的方法

 

{dede:productimagelist}织梦图集标签给img添加alt属性时默认要调用的是注释(即:[field:text/]),可是为了节省时间和劳动力,跟版网小编不想给每张图片都填写注释而是想直接调用标题,也就是想用[field:title/]标签,试了下,结果不行,跟版网模板通过源代码的修改,终于搞定了,希望这个修改经验对你有所帮助。

 

源代码修改:

打开 \include\taglib\productimagelist.lib.php 文件

找到(约20行):

 

<span style="font-family:tahoma,geneva,sans-serif;"><span style="font-size:14px;">if(!isset($refObj->addTableRow['imgurls'])) return ;</span></span>

 

在此代码下边添加如下代码:

 

<span style="font-family:tahoma,geneva,sans-serif;"><span style="font-size:14px;">$aid = $refObj->ArcID;

$row = $refObj->dsql->GetOne("SELECT title FROM `dede_archives` WHERE `id` = '$aid';");

$title = $row['title'];</span></span>

 

找到(约41行):

 

<span style="font-family:tahoma,geneva,sans-serif;"><span style="font-size:14px;">$row['text'] = $ctag->GetAtt('text');</span></span>

 

在此代码下边添加如下代码:

 

<span style="font-family:tahoma,geneva,sans-serif;"><span style="font-size:14px;">$row['title'] = $title;</span></span>

 

调用代码:

 

<span style="font-family:tahoma,geneva,sans-serif;"><span style="font-size:14px;">[field:title/]</span></span>

 

示例:

 

<span style="font-family:tahoma,geneva,sans-serif;"><span style="font-size:14px;">{dede:productimagelist}

<li><a href="javascript:ChangePic('[field:imgsrc/]', '#bigpicimg');" title="[field:text/]_www.genban.org" rel="facebox"><img src="[field:imgsrc/]" width="120" height="90" alt="[field:title/]" /></a></li>

{/dede:productimagelist}</span></span>


 

评论列表暂无评论
发表评论
微信