Posted on 10/06/2008 10:20:38
paul wrote:
I want to create a custom module with a template tag loop inside another template tag loop.
The firts loop contains a datarow and then for every datarow there is another loop with datarows
How do I create the second loop inside the first one?
You can have loops in loops like this in code:
Dim t As New Templatev2.Template("MyModule/Template.html")
t.SetTag("HelloText", "Hello there...")
Dim FirstLoopTemplate As Templatev2.Template = t.GetLoop("FirstLoop")
For i As Integer = 0 To 10
FirstLoopTemplate.SetTag("FirstLoopCounter", i)
Dim SecondLoopTemplate As Templatev2.Template = FirstLoopTemplate.GetLoop("SecondLoop")
For x As Integer = 0 To 5
SecondLoopTemplate.SetTag("SecondLoopCounter", x)
SecondLoopTemplate.CommitLoop()
Next
FirstLoopTemplate.CommitLoop()
Next
Dim output As String = t.Output
With a template like this: The template says: <!--@HelloText--><br>
<ul>
<!--LoopStart(FirstLoop)-->
<li><!--@FirstLoopCounter--></li>
<ul>
<!--LoopStart(SecondLoop)-->
<li><!--SecondLoopCounter--></li>
<!--LoopEnd(SecondLoop)-->
</ul>
<!--LoopEnd(FirstLoop)-->
</ul>