轻源码

  • QingYuanMa.com
  • 全球最大的互联网技术和资源下载平台
搜索
一起源码网 门户 织梦CMS 查看主题

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

发布者: soccerboy | 发布时间: 2019-1-1 17:25| 查看数: 3774| 评论数: 1|帖子模式

前段时间有一篇文章介绍autoindex标签的使用,但只是简单的在文章前面加个编号,今天详细整理了一下这个标签的具体用法:
织梦制作时,我们需要每循环一次,变量加一,这是就需要使用到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'];


最新评论

lzxb 发表于 2022-7-16 11:16
源代码素材

浏览过的版块

轻源码让程序更轻更快

QingYuanMa.com

工作时间 周一至周六 8:00-17:30

侵权处理

客服QQ点击咨询

关注抖音号

定期抽VIP

Copyright © 2016-2021 https://www.171739.xyz/ 滇ICP备13200218号

快速回复 返回顶部 返回列表