dede循环递增autoindex使用方法

下面是编程之家 jb51.cc 通过网络收集整理的代码片段。编程之家小编现在分享给大家,也给大家做个参考。

当我们用 dede 做网站时,有时候需要用到每循环一次,变量加一,这是就需要使用到 autoindex 标签。

代码写法如下:

{dede:arclist titlelen='26' row='10'}

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

[field:global name=autoindex runphp="yes"]if(@me%5==0)@me="<br/>";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="<br/>";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'];

以上是编程之家(jb51.cc)为你收集整理的全部代码内容,希望文章能够帮你解决所遇到的程序开发问题。如果觉得编程之家网站内容还不错,欢迎将编程之家网站推荐给程序员好友。

相关文章

文章浏览阅读483次。dedecms织梦频道模板中调用栏目分类并排...
文章浏览阅读284次。我们在用织梦建站的过程中,难免会遇到各...
文章浏览阅读152次。seo专题是seo优化必不可少的一环,对于网...
文章浏览阅读142次。在Dedecms中,在列表页调用文章摘要的方...
文章浏览阅读234次。织梦DedeCMS文章内容发布时可以选择“头...
文章浏览阅读701次。虽然织梦DedeCMS因为安全问题被人所诟病...