POST TIME:2021-05-23 02:59
今天看見一個標簽[field:global runphp='yes' name=autoindex][/field:global]開始有點奇怪他的原理,后來分析了下源碼。還是很簡單的。
arclist標簽在執(zhí)行過程中,會聲明一個全局變量$GLOBALS['autoindex']=0,然后隨著執(zhí)行每一條數(shù)據(jù)對其自增長$GLOBALS['autoindex']++,而runphp='yes'是你想在標簽內(nèi)進行有限的PHP編程前必須聲明的。
織夢列表自動編號的方法(注意autoindex itemindex 的使用心得區(qū)別 ):
[field:global name=autoindex runphp=
"yes"
]@me=@me+
1
;[/field:global]
{dede:global name=itemindex runphp=
"yes"
}@me=@me+
1
;{/dede:global}
其他幾個列表標簽的自增長如下,在網(wǎng)上找的,新版是否一樣還需要驗證
arclist 標簽下使用 [field:global.autoindex/] 默認從1開始
channel 標簽下使用 [field:global.autoindex/] 默認從0開始
channelartlist 標簽下使用 {dede:global.itemindex/} 默認從1開始
對這個自增標簽進行一個簡單的小擴展,
< span style = "font-size:16px;" >[field:global runphp='yes' name=autoindex] if (@me < 9) @me = 0.@me; else @me = @me; [/field:global] </ span > |
這樣就會顯示 01 02 03...09這樣的編號列表樣式