在織夢dedecms默認功能有圖片集的功能,在內容調用圖片集的時候如果要使用一些插件或幻燈片的時候,可能就會用到ID,但是默認是不會添加編號的,所以要讓{dede:productimagelist}標簽支持自動編號。
打開include/taglib/productimagelist.lib.php文件,找到:
$ctp->LoadSource($innerText);
在后面加入
$GLOBALS['autoindex'] = 0;
找到:
$revalue .= $ctp->GetResult();
在后面加入
$GLOBALS['autoindex']++;
接下來就是html中的了:
[field:global name=autoindex/]
例子:
{dede:productimagelist}
<span id="[field:global name=autoindex/]"><img src="[field:imgsrc/]" width="805" height="523" /></span>
{/dede:productimagelist}
假如有3個圖片,則結果為:
復制代碼代碼如下:
<span id="0"><img src="1.jpg" width="805" height="523" /></span>
<span id="1"><img src="2.jpg" width="805" height="523" /></span>
<span id="2"><img src="3.jpg" width="805" height="523" /></span>
這樣就可以自動給圖片加上了編號,這樣能更好的分辨圖片。