我們在開發(fā)織夢模板時,如果用到dede:productimagelist標簽發(fā)現(xiàn)沒有autoindex自動索引,使用[field:global.autoindex/]無法調用。島主二次開發(fā)了一下,讓dede:productimagelist標簽支持autoindex。
1:打開/include/taglib/productimagelist.lib.php 找到:
foreach($images as $row)
在其上面增加如下代碼
$GLOBALS['autoindex'] = 1;
//如果您希望autoindex 的起始值從0開始,把1修改成0即可。
繼續(xù)找到如下代碼:
$revalue .= $ctp->GetResult();
在其下面增加:
$GLOBALS['autoindex']++;
完成。
2:標簽調用:
{dede:productimagelist} <span id="[field:global name=autoindex/]"><img src="[field:imgsrc/]" /></span>
{/dede:productimagelist} <span id="0"><img src="1.jpg" /></span> <span id="1"><img src="2.jpg" /></span> <span id="2"><img src="3.jpg" /></span> |
或者使用:
{dede:productimagelist} <div class="item [field:global runphp='yes' name=autoindex](@me < 2)?@me="active":@me="";[/field:global]"> <img src="[field:imgsrc/]"/> </div>
{/dede:productimagelist} <div class="item "> <img src="/2.jpg"/> </div>
<div class="item "> <img src="/3.jpg"/> </div>
|