织梦DedeCms在图集标签(productimagelist)中添加自增数字编号

2018-11-22 二次开发 浏览 手机预览
文章来源:http://www.imtr.cn/html/n217.html

源代码修改:
打开 /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="织梦OK" width="200" height="300" /></span>
{/dede:productimagelist}


输出html代码示例:
<span id="0"><img src="1.jpg" alt="织梦OK" width="200" height="300" /></span>
<span id="1"><img src="2.jpg" alt="织梦OK" width="200" height="300" /></span>
<span id="2"><img src="3.jpg" alt="织梦OK" width="200" height="300" /></span>

原文地址:http://www.imtr.cn/html/n217.html
  • 如果你的问题还没有解决,可以点击页面右侧的“ ”,站长收到问题后会尽快回复解决方案到你的邮箱。
  • 创造始于问题,有了问题才会思考,有了思考,才有解决问题的方法,才有找到独立思路的可能。 —— 陶行知