织梦dedecms版面标签数字递增,数字自动循环递增autoindex

织梦dedecms模板制作时,有时需要每循环一次,变量自动加一或者是数字循环递增加1并输出相应的数字,这是就需要使用到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]
//开源软件:Cuoxin.com
{/dede:arclist}
上面的代码即为autoindex标签用法,意思是,循环调用文章时,到第五条时输出,否则输出空,这样我们就实现了第五篇文章下面进行换行.
 
织梦dedecms版面标签数字递增,数字自动循环递增autoindex

配合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="
";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'];

dawei

【声明】:邵阳站长网内容转载自互联网,其相关言论仅代表作者个人观点绝非权威,不代表本站立场。如您发现内容存在版权问题,请提交相关链接至邮箱:bqsm@foxmail.com,我们将及时予以处理。