加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > CMS系统 > Dedecms > 正文

dedecms循环递增autoindex使用方法整理

发布时间:2020-12-14 03:56:53 所属栏目:Dedecms 来源:网络整理
导读:织梦 dedecms模板 制作时,我们需要每循环一次,变量加一,这是就需要使用到autoindex标签。代码写法如下: {dede:arclist titlelen='26' row='10'} [field:global name=autoindex runphp="yes"]if(@me%5==0)@me=" ";else @me="";[/field:global] {/dede:arc

织梦dedecms模板制作时,我们需要每循环一次,变量加一,这是就需要使用到autoindex标签。代码写法如下:

{dede:arclist titlelen='26' row='10'}

  • [field:global name=autoindex runphp="yes"]if(@me%5==0)@me="
    ";else @me="";[/field:global]

    {/dede:arclist}

    红色的即为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'];

    (编辑:李大同)

    【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

      推荐文章
        热点阅读