TMS中关于“嵌套循环”的解决方案

接触TMS近一个月了,对TMS不支持嵌套很不习惯,不支持嵌套循环更不习惯。面对二层及二层以上的循环,我们该如何去实现呢?

关于二层循环

一、使用custom定义变量1、变量2、变量3…(笨方法)。如:

 1 <cms:custom group=”test_循环” title=”循环” fields=”text1:文字1:string,text2:文字2:string,text3:文字3:string,text4:文字4:string,text5:文字5:string” row=”3″ defaultRow=”3″>
2 #foreach($item in $customList)
3 <ul>
4 <li>$!item.text1</li>
5 <li>$!item.text2</li>
6 <li>$!item.text3</li>
7 <li>$!item.text4</li>
8 <li>$!item.text5</li>
9 </ul>
10 #end
11 </cms:custom>

改进:

1 <cms:custom group=”test_循环” title=”循环” fields=”text1:文字1:string,text2:文字2:string,text3:文字3:string,text4:文字4:string,text5:文字5:string” row=”3″ defaultRow=”3″>
2 #foreach($item in $customList)
3 <ul>
4 <li>$!item.text+$velocityCount</li>
5 </ul>
6 #end
7 </cms:custom>

 

二、使用repeat。如:

1 <cms:repeat group=”test_循环” title=”循环” row=”3″>
2 <ul>
3 <cms:text group=”test_循环” title=”循环” row=”5″ defaultRow=”3″>
4 #foreach($item in $customList)
5 <li>$!item.text</li>
6 #end
7 </cms:text>
8 </ul>
9 </cms:repeat>

ps:此方法第二层循环可以并行多个,不过第二层不能再嵌套。

 

关于二层以上的循环

一、治标不治本的:
(1) 使用subArea:
(2) 使用#foreach($i in [])…#end

posted on 2012-03-09 11:24  jndream  阅读(334)  评论(0编辑  收藏  举报