DEDECMS教程:給圖片加上自動(dòng)編號(hào)

字號(hào):


    在圖集內(nèi)容頁調(diào)用圖集的時(shí)候,如果使用某些幻燈片特效或者jquery插件,難免會(huì)用到ID編號(hào)什么的,本教程將教會(huì)你如何給圖集圖片自動(dòng)編號(hào),也就是說,讓{dede:productimagelist}標(biāo)簽支持自動(dòng)編號(hào),非常簡(jiǎn)單。
    打開include/taglib/productimagelist.lib.php文件,找到:
    $ctp->LoadSource($innerText);
    在其后面另起一行加入
    $GLOBALS['autoindex'] = 0;
    找到:
    $revalue .= $ctp->GetResult();
    在其后面另起一行加入
    $GLOBALS['autoindex']++;
    這里的改動(dòng)就算完了,接下來是內(nèi)容頁里調(diào)用:
    [field:global name=autoindex/]
    例子:
    {dede:productimagelist}
    <span id="[field:global name=autoindex/]"><img src="[field:imgsrc/]" width="805" height="523" /></span>
    {/dede:productimagelist}
    假如有3個(gè)圖片,則結(jié)果為:
    <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>
    你學(xué)會(huì)了么?