Developer forum

Forum » Templates » Loops in templates

Loops in templates


Reply

I've been trying to find more information about how to use Loops in templates, and in particular, how to use them with the Related Links module on a page.


 


I have created a link group with two links, and I have added it to the Links tag of a page. But nothing outputs. When looking at the DWTemplateTags output, I've found out that it should have access to a loop:


 


(0)


But when I insert this in a template, it only outputs:


 


!--@LoopOutput(FreebiesLoop_0)--


 


How do I get it to loop though the links in the group, and how do I know what element tags I have available and what they are called?


 


I am sure that Sebastian mentioned Loops on the Template training, and I am almost sure that he mentioned them in the videoguides. However, I cant seem to find these videoguides on your websites (www.dynamicweb.dk, developer.dynamicweb.dk, templates.dynamicweb.dk) Have you removed these guides?


 


Any help will be greatly appreciated :)


Replies

 
Reply

Hi Sune


When you use the loop you can use @DwTemplateTags between your 2 loop tags like this:




@LoopStart(FreebiesLoop_0)

    @DwTemplateTags

@LoopEnd(FreebiesLoop_0)


 


Then you will get a list of tags that is available within the loop

 
Reply

The videoguides are located right her:

http://developer.dynamicweb.dk/default.aspx?id=16918&action=ShowArticle&ArticleID=4


 


But I don't think they include much looping.

 
Reply
Dammark wrote:


Hi Sune




When you use the loop you can use @DwTemplateTags between your 2 loop tags like this:




@LoopStart(FreebiesLoop_0)



    @DwTemplateTags



@LoopEnd(FreebiesLoop_0)




 Then you will get a list of tags that is available within the loop





I must miss something vital in this setup, because no matter what I try, I cant get the loop to output anything :-/


 


Do I need to insert any module for the Related Links to show?

 
Reply

Do you have a link for the website ?

 
Reply

You've done it almost correct ...


 


After creating the group you have to go onto a page fx. the frontpage.  When you click this page in the admin you get 2 tabs.


 


Tab 1 is paragraphs and Tab 2 is Links.


 


In the links tab you can add the Group called Freebies and start adding links to that group.


 


I've already added 1 link, my own website.


 


Now you can see @LoopStart(FreebiesLoop) in the output from @DwTemplateTags


 


// Sebastian

 
Reply
Dammark wrote:


You've done it almost correct ...




 




After creating the group you have to go onto a page fx. the frontpage.  When you click this page in the admin you get 2 tabs.




 




Tab 1 is paragraphs and Tab 2 is Links.




 




In the links tab you can add the Group called Freebies and start adding links to that group.




 




I've already added 1 link, my own website.




 




Now you can see @LoopStart(FreebiesLoop) in the output from @DwTemplateTags




 




// Sebastian





Yes, I can see the start and end tags in the DwTemplateTags output, but nothing happens when I insert these tags on a page. Also, the DwTemplateTags output lists them with a size of [0].


 


It doesnt matter wether I use the LoopStart tag in the source of a paragraph, or if I use it in a ParagraphTemplate file. I cant make it output anything. What am I doing wrong? :)

 
Reply

You can only use this tag in the pagetemplate.

 
Reply
Dammark wrote:


You can only use this tag in the pagetemplate.





Ah! That explains it! :)


My next question is now, what does the LoopMod2, LoopMod3 etc mean?

 

You must be logged in to post in the forum