建站代码网

热门标签

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

源代码修改:
打开 /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="data:image/svg+xml,%3Csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%20480%20640'%3E%3C/svg%3E" loading='lazy' data-lazy-src="http://1.com/skin/default/image/nopic.gif" alt="www.cmsjzy.cn" width="200" height="300" /></span>
{/dede:productimagelist}
输出html代码:
<span id="0"><img src="data:image/svg+xml,%3Csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%20480%20640'%3E%3C/svg%3E" loading='lazy' data-lazy-src="http://1.com/skin/default/image/nopic.gif" alt="www.cmsjzy.cn" width="200" height="300" /></span>
<span id="1"><img src="data:image/svg+xml,%3Csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%20480%20640'%3E%3C/svg%3E" loading='lazy' data-lazy-src="http://1.com/skin/default/image/nopic.gif" alt="www.cmsjzy.cn" width="200" height="300" /></span>
<span id="2"><img src="data:image/svg+xml,%3Csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%20480%20640'%3E%3C/svg%3E" loading='lazy' data-lazy-src="http://1.com/skin/default/image/nopic.gif" alt="www.cmsjzy.cn" width="200" height="300" /></span>
X