查看: 64|回复: 0

[教程] 织梦dedecms循环中判断当前第几条数据(autoindex)

[复制链接]

2

主题

0

回帖

0

积分

积极分子

金币
0
阅读权限
220
精华
0
威望
0
贡献
0
在线时间
0 小时
注册时间
2008-3-25
发表于 2025-3-22 00:00:00 | 显示全部楼层 |阅读模式

在织梦CMS(内容管理系统)中有一个标签,可以获得当前处理的是第几条数据,即数据的索引,这个标签就是 [field:global name='autoindex' /] 。 arclist 标签下使用 [field:global.autoindex/] 默认从1开始。

arclist标签

{dede:arclist row='10' titlelen='48' typeid='1' channelid='1'}

从1开始:[field:global runphp='yes' name=autoindex][/field:global]或者[field:global.autoindex/]

从0开始:[field:globalrunphp='yes' name=autoindex]@me=@me-1;[/field:global]

{/dede:arclist}

channel 标签

channel 标签下使用 [field:global.autoindex/] 默认从0开始

{dede:channel row='5' type='top'}

从0开始:[field:global runphp='yes' name=autoindex][/field:global]或者[field:global.autoindex/]

从1开始:[field:globalrunphp='yes' name=autoindex]@me=@me+1;[/field:global]

{/dede:channel}

channelartlist 标签

channelartlist 标签下使用 {dede:global.itemindex/} 默认从1开始

{dede:channelartlist row='4'}

从1开始:{dede:global name=itemindex runphp='yes'}{/dede:global}或者{dede:global.itemindex/}

从1开始:{dede:global name=itemindex runphp='yes'}@me=@me-1;{/dede:global}

{/dede:channelartlist}

list到第10条时输出<br/>,否则输出空

循环到第几条加条线同理

{dede:list pagesize='40' orderby='id'}

<li><a title="[field:title function='htmlspecialchars(@me)'/] " href="[field:arcurl /]">[field:title /]</a></li>

[field:global name='autoindex' runphp='yes']if(@me%10==0){@me="<br/>";}else{@me='';}[/field:global]

{/dede:list}


回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

相关侵权、举报、投诉及建议等,请发 E-mail:qiongdian@foxmail.com

Powered by Discuz! X5.0 © 2001-2026 Discuz! Team.

在本版发帖返回顶部