本文主要讲解《dede循环递增auoidex使用方法》的详细内容
当我们用dede做网站时,有时候需要用到每循环一次,变量加一,这是就需要使用到autoindex标签。
代码写法如下:
{dede:arclisttitlelen='26'row='10'}
<li><atitle="[field:titlefunction='htmlspecialchars(@me)'/]"href="[field:arcurl/]">[field:title/]</a></li>
[field:globalname=autoindexrunphp="yes"]if(@me%5==0)@me="<br/>";else@me="";[/field:global]
{/dede:arclist}
红色的即为autoindex标签用法。意思是,循环调用文章时,到第五条时输出<br/>,否则输出空。这样我们就实现了第五篇文章下面进行换行。配合css和简单的php等代码使用,达到更多效果。
循环+1的写法:
[field:globalname=autoindexrunphp="yes"]@me=@me+1;[/field:global]
频道页使用时可以换成itemindex标签,原理同autoindex
{dede:globalname='itemindex'/}
{dede:globalname='itemindex'runphp='yes'}if(@me%5==0)@me="<br/>";else@me="";{/dede:global}
{dede:globalname='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'];
本网刊登的文章均仅代表作者个人观点,并不代表本网立场。文中的论述和观点,敬请读者注意判断。
2021-02-08
2021-02-08
2021-02-08
2021-02-08
2021-02-08
2021-02-24
2021-02-24
2021-02-08