`

dedecms 循环列表问题

 
阅读更多

当需要循环数字时:



{dede:arclist typeid='16' row='3' titlelen='24' orderby ='scores' limit='0,3'}
				<div class="sgpm2">
					<div class="sgpm2_1">[field:global.autoindex/]</div>
					<div class="sgpm2_2"><a href="[field:arcurl/]">[field:title/]</a></div>
					<div class="sgpm2_3">[field:scores/]</div>
				</div>
				{/dede:arclist}
				
				{dede:arclist typeid='16' row='4' titlelen='24' orderby ='scores' limit='3,4'}
				<div class="sgpm3">
					<div class="sgpm3_1">[field:global name=autoindex runphp="yes"]@me=@me+3;[/field:global]</div>
					<div class="sgpm3_2"><a href="[field:arcurl/]">[field:title/]</a></div>
					<div class="sgpm3_3">[field:scores/]</div>
				</div>
				{/dede:arclist}


////////////////////////////////////////////


以下转自:http://www.maihui123.com/dedecms/2012051964.html


织梦dedecms模板制作时,循环递增autoindex使用方法整理

发布时间:2012-05-19 22:14来源:未知点击:1509

织梦dedecms模板制作时,我们需要每循环一次,变量加一,这是就需要使用到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标签用法。意思是,循环调用文章时,到第五条时输出<br/>,否则输出空。这样我们就实现了第五篇文章下面进行换行。配合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'];



分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics