POST TIME:2017-10-29 21:49
當我們用dede做網站時,有時候需要用到每循環一次,變量加一,這是就需要使用到autoindex標簽。
代碼寫法如下:
{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標簽用法。意思是,循環調用文章時,到第五條時輸出<br/>,否則輸出空。這樣我們就實現了第五篇文章下面進行換行。配合css和簡單的php等代碼使用,達到更多效果。
循環+1的寫法:
[field:global name=autoindex runphp="yes"]@me=@me+1;[/field:global]
頻道頁使用時可以換成itemindex標簽,原理同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}
織夢默認的搜索頁不支持autoindex標簽,需要修改核心文件增加支持:
找到文件: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'];