關于織夢的循環遞增autoindex標簽的使用,織夢模板網前面已經做過總結和講述《DedeCMS自增函數autoindex/itemindex用法全解析》,因為有朋友再次咨詢到,所以這邊我們就再拿出來講一下。
當我們用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}[field:global name=autoindex runphp="yes"]if(@me%5==0)@me="<br/>";else @me="";[/field:global]
上面紅色的部分即為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'];
擴展閱讀:
《如何在{dede:sql}這個標簽中使用自增函數[field:global.autoindex/]》
《織夢dede:channel標簽支持autoindex數字遞增標簽教程》
《織夢自增函數autoindex和itemindex功能介紹》
《織夢圖集dede:productimagelist標簽增加autoindex遞增自動編號》
《織夢自增標簽[field:global name=autoindex/]用法介紹》
《織夢dede:tag標簽實現autoindex自增功能方法》
《織夢搜索頁面模板如何實現autoindex排序》
以上就是織夢模板制作分享dede循環遞增autoindex使用方法的全部內容,希望對大家的學習和解決疑問有所幫助,也希望大家多多支持武林網。新聞熱點
疑難解答