DEDECMS自动编号(序号)autoindex属性(转)

本文介绍在织梦CMS中如何通过autoindex和itemindex实现从0或1开始的自增索引,适用于不同标签如arclist、channelartlist和channel。文章详细展示了在各种标签下使用自增索引的方法,包括修改起始值和在不同场景下的应用实例。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

让织梦dedecms autoindex,itemindex 从0到1开始的办法!

 

1

2

3

[field:global name=autoindex runphp="yes"]@me=@me+1;[/field:global]

  

{dede:global name=itemindex runphp="yes"}@me=@me+1;{/dede:global}

 autoindex   itemindex 的使用心得区别  

 

channelartlist 标签下使用 

1

{dede:global name='itemindex' runphp='yes'}@me;{/dede:global}

自增1

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

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

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

 

arclist  从0开始 [field:global name=autoindex runphp="yes"]@me=@me-1;[/field:global]

channel  从1开始 [field:global name=autoindex runphp="yes"]@me=@me+1;[/field:global][field:typename/]

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

 

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

<div id="h_pd_lm_{dede:global.itemindex/}" {dede:global name='itemindex' runphp='yes'}@me=(@me==1)?'':'style="display:none;"';{/dede:global} class="pd2_lmc_l1">

  

eg---->

  

{dede:channelartlist  notypeid='123,124,146,147'}

     <a class="pd2_lmt{dede:global name=itemindex runphp='yes'}@me=(@me==1)?'1':'3';{/dede:global}" onmouseover="showitem2({dede:global name=itemindex runphp='yes'}@me=@me-1;{/dede:global},'pd_lm','h_pd_lm_','pd2_lmt');" href='{dede:field name='typeurl'/}'>

{dede:php}if($refObj->Fields['ispart']){echo $refObj->Fields['typename'];}{/dede:php}

     </a>

{/dede:channelartlist}

  

{dede:channelartlist typeid="1" row="8" }

<div class="combz01" {dede:global name=itemindex runphp='yes'}if(@me==2)@me='id="with"';if(@me==5)@me='id="with"';if(@me==7)@me='id="with"';{/dede:global}>

<div class="combz01title"><a href="{dede:field name='typeurl'/}" title="{dede:field name='typename'/}" target="_blank"><b>{dede:field name='typename'/}</b></a><u><a href="{dede:field name='typeurl'/}" title="{dede:field name='typename'/}" target="_blank">更多>></a></u></div>

<div class="comcon">

{dede:arclist titlelen='42' row='1' flag='c'}

<img src="[field:litpic/]" width="127" height="94"/>

<i>[field:description function="cn_substr(@me,100)"/]...<a href="[field:arcurl /]" title="[field:fulltitle/]" target="_blank">[详情]</a></i>

{/dede:arclist}

</div>

<div class="comconlist">

<ul>

 {dede:arclist titlelen="42" row="3"}

 <li><a href="[field:arcurl /]">[field:title /]</a></li>

 {/dede:arclist}

</ul>

</div>

</div>

{/dede:channelartlist}

channel 标签下使用[field:global name=autoindex/]  

1

2

3

4

5

6

7

8

9

10

11

12

13

eg---->

 

{dede:channel titlelen='32'}

        <li [field:global name='autoindex' runphp='yes']if(@me%2==0){@me='class="rr"';}else{@me='';}[/field:global] ><h3><a href='[field:typelink/]'>[field:typename/]</a></h3></li>

{/dede:channel}

 

 

 

在arclist中使用autoindex runphp 时用这种方式:

 

{dede:arclist titlelen='22' row='4' flag='c' orderby='id'}

      <a href="[field:arcurl /]" target="_blank">[field:title /]</a>

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

 

自增1

 [field:global.autoindex/]

1

2

3

4

5

6

7

eg---->

 

{dede:arclist channelid=17 row=6 orderby=pubdate titlelen=40 addfields='docphoto,docjob,doctec' typeid='123,136,146,155,172,182,202'}

                <div id="h_nrr_zj_[field:global.autoindex/]" class="nrr_zjl" [field:global name='autoindex' runphp='yes']if(@me==1){@me="";}else{@me='style="display:none;"';}[/field:global] >

                <div><a href="[field:arcurl/]" title="[field:fulltitle/]" target="_blank"><img src="[field:litpic/]" alt="[field:fulltitle/]" /></a></div>

</div>

{/dede:arclist}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值