注册 登录 欢迎您到模板精:织梦模板_dede模板_免费网站模板_网站源码下载

织梦教程_免费织梦模板下载_dede模板

该栏目分享织梦建站的基础知识,从织梦CMS的安装,到织梦标签的常规调用,以及织梦的常见问题答疑都有涉及。

当前位置:首页 > 织梦教程 >

织梦dedecms给productimagelist图集标签添加数字编号自增递增的

免费网站模板 2020-09-17 10:54 织梦教程 评论
源代码修改:
打开 /include/taglib/productimagelist.lib.php 文件
 
找到:
$ctp->LoadSource($innerText);
 
在此代码下边添加如下代码:
$GLOBALS['autoindex'] = 0;
 
找到:
$revalue .= $ctp->GetResult();
在此代码下边添加如下代码:
 
$GLOBALS['autoindex']++;
 
调用代码:
[field:global name=autoindex/]
 
示例:
{dede:productimagelist}
<span id="[field:global name=autoindex/]"><img src="[field:imgsrc/]" alt="www.adminbuy.cn" width="200" height="300" /></span>
{/dede:productimagelist}
 
输出html代码:
<span id="0"><img src="1.jpg" alt="www.adminbuy.cn" width="200" height="300" /></span>
<span id="1"><img src="2.jpg" alt="www.adminbuy.cn" width="200" height="300" /></span>
<span id="2"><img src="3.jpg" alt="www.adminbuy.cn" width="200" height="300" /></span>