织梦标签 [field:global.autoindex/]的使用

在织梦的{dede:arclist/}的标签中,有一个非常有用的,[field:global.autoindex/],这个标签是一个自增长标签,他的值是从1开始,跟着你的列表自动自增,在我们给网站加入一些效果时候会非常有用。

这里再介绍一下,如果想让他从0开始自增的方法
[field:autoindex runphp='yes']@me=$GLOBALS['autoindex']-1;[/field:autoindex],这里的-1是重点,如果想从2开始自增就是+1以此类推

这个标签默认在sql标签中是不可以使用的,如果希望在sql语句的标签中加入,可以这样做。比如我们想修在{dede:sql/}标签中使用

首先找到 /includ/taglib文件夹下的sql.lib.php文件

打开后我们找到第34行,也就是代码 $ctp->LoadSource($Innertext); 处,
    
在下面加上以下一段代码:$GLOBALS['autoindex'] = 0; 这段代码就是定义一个全局变量,并赋值为0,

接下来我们只需要将下面代码进行下修改: 

while($row = $dsql->GetArray($thisrs))
{
$sqlCt++;
foreach($ctp->CTags as $tagid=>$ctag){
if(!empty($row[$ctag->GetName()])){ $ctp->Assign($tagid,$row[$ctag->GetName()]); }
}
$GLOBALS['autoindex']++;  //每循环一次加上一个1然后解析出来
$revalue .= $ctp->GetResult();
}

这样一来,这个[field:global.autoindex/]标签就可以在那个{dede:sql/}中使用了,我们举个例子:

{dede:sql sql='select * from [url=mailto:#@__archives]#@__archives'[/url]}
[field:global.autoindex/]-[field:title/]</br>
{/dede:sql}


itemindex在channelarclist中的使用类似于autoindex

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.如果要实现排行榜,前三名的样式不一样
[field:global runphp='yes' name=autoindex]      
$a="<SPAN class='ico1'>";  $b="</SPAN>";     $c="<SPAN class='ico2'>"; if (@me > 3) @me = $c.@me.$b; else @me = $a.@me.$b; 
[/field:global] 

如果样式  都是不同的 还可以这样定义
[field:global runphp='yes' name=autoindex]      $a="<SPAN class='icon@me'>";  $b="</SPAN>";     $c="<SPAN class='ico2'>"; if (@me > 3) @me = $c.@me.$b; else @me = $a.@me.$b; [/field:global]

转载于:https://www.cnblogs.com/FanTasYX/p/3259884.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
2023/07/24 15:14:58 [error] 721#0: *763 client intended to send too large body: 113069413 bytes, client: 101.83.232.139, server: hetx.top, request: "PUT /index.php/dav/my/%E6%96%87%E4%BB%B6/XMind2022%EF%BC%8864bit%EF%BC%89/XMind2022%EF%BC%8864bit%EF%BC%89/app.asar HTTP/2.0", host: "hetx.top" 2023/07/24 15:15:06 [error] 721#0: *763 client intended to send too large body: 113069413 bytes, client: 101.83.232.139, server: hetx.top, request: "PUT /index.php/dav/my/%E6%96%87%E4%BB%B6/XMind2022%EF%BC%8864bit%EF%BC%89/XMind2022%EF%BC%8864bit%EF%BC%89/app.asar HTTP/2.0", host: "hetx.top" 2023/07/24 15:16:12 [error] 721#0: *763 client intended to send too large body: 134120318 bytes, client: 101.83.232.139, server: hetx.top, request: "PUT /index.php/dav/my/%E6%96%87%E4%BB%B6/XMind2022%EF%BC%8864bit%EF%BC%89.7z HTTP/2.0", host: "hetx.top" 2023/07/24 15:16:40 [error] 721#0: *763 client intended to send too large body: 134120318 bytes, client: 101.83.232.139, server: hetx.top, request: "PUT /index.php/dav/my/%E6%96%87%E4%BB%B6/XMind2022%EF%BC%8864bit%EF%BC%89.7z HTTP/2.0", host: "hetx.top" 2023/07/24 15:16:43 [error] 721#0: *763 client intended to send too large body: 134120318 bytes, client: 101.83.232.139, server: hetx.top, request: "PUT /index.php/dav/my/%E6%96%87%E4%BB%B6/XMind2022%EF%BC%8864bit%EF%BC%89.7z HTTP/2.0", host: "hetx.top" 2023/07/24 15:16:45 [error] 721#0: *763 client intended to send too large body: 134120318 bytes, client: 101.83.232.139, server: hetx.top, request: "PUT /index.php/dav/my/%E6%96%87%E4%BB%B6/XMind2022%EF%BC%8864bit%EF%BC%89.7z HTTP/2.0", host: "hetx.top" 2023/07/24 15:19:37 [error] 721#0: *878 client intended to send too large body: 134120318 bytes, client: 101.83.232.139, server: hetx.top, request: "PUT /index.php/dav/my/%E6%96%87%E4%BB%B6/XMind2022%EF%BC%8864bit%EF%BC%89.7z HTTP/2.0", host: "hetx.top" 2023/07/24 15:20:30 [error] 721#0: *878 client intended to send too large body: 134120318 bytes, client: 101.83.232.139, server: hetx.top, request: "PUT /index.php/dav/my/XMind2022%EF%BC%8864bit%EF%BC%89.7z HTTP/2.0", host: "hetx.top" 2023/07/24 15:31:12 [error] 1209#0: *28 client intended to send too large body: 134120318 bytes, client: 101.83.232.139, server: hetx.top, request: "PUT /index.php/dav/my/%E6%96%87%E4%BB%B6/XMind2022%EF%BC%8864bit%EF%BC%89.7z HTTP/2.0", host: "hetx.top" 2023/07/24 15:42:10 [error] 1209#0: *110 directory index of "/www/wwwroot/hetx.top/static/" is forbidden, client: 113.142.131.55, server: hetx.top, request: "GET /static/ HTTP/1.1", host: "hetx.top"
最新发布
07-25
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值