POST TIME:2017-10-27 22:26
前段時間有一篇文章介紹autoindex標(biāo)簽的使用,但只是簡單的在文章前面加個編號,今天詳細(xì)整理了一下這個標(biāo)簽的具體用法:
織夢dedecms模板制作時,我們需要每循環(huán)一次,變量加一,這是就需要使用到autoindex標(biāo)簽。代碼寫法如下:
{dede:arclist titlelen='26' row='10'}
<li><a title="[field:title function='htmlspecialchars(@me)'/] " href="[field:arcurl /]">[field:title /]</a></li>
[field:global name=autoindex runphp="yes"]if(@me%5==0)@me="<br/>";else @me="";[/field:global]
{/dede:arclist}
紅色的即為autoindex標(biāo)簽用法。意思是,循環(huán)調(diào)用文章時,到第五條時輸出<br/>,否則輸出空。這樣我們就實(shí)現(xiàn)了第五篇文章下面進(jìn)行換行。配合css和簡單的php等代碼使用,達(dá)到更多效果。
循環(huán)+1的寫法:
[field:global name=autoindex runphp="yes"]@me=@me+1;[/field:global]
頻道頁使用時可以換成itemindex標(biāo)簽,原理同autoindex
{dede:global name='itemindex'/}
{dede:global name='itemindex' runphp='yes'}if(@me%5==0)@me="<br/>";else @me="";{/dede:global}
{dede:global name='itemindex' runphp='yes'}@me=@me+1;{/dede:global}
織夢默認(rèn)的搜索頁不支持autoindex標(biāo)簽,需要修改核心文件增加支持:
找到文件:include/arc.searchview.class.php
里面找到代碼:$this->dtp2->LoadSource($innertext);
下面加上:
$GLOBALS['autoindex'] = 0;
------------------------------------
if($row = $this->dsql->GetArray("al"))
{
下面加上:
$GLOBALS['autoindex']++;
$ids[$row['id']] = $row['id'];