Developer forum

Forum » Templates » Getting loop index

Getting loop index

Jonas Mersholm
Reply

Hi there.

Say i have a content placeholder

<div class="dwcontent" title="Slide" id="slider" settings="template:slide.cshtml"></div>

 

How would i get the current loop index in the template file specified in the "settings" attribute - so that i can add "active" class to the first element (vice versa)  - when theres no foreach or direct iteration in the template file



                            <div class="item">
                              <img src="@GetValue("Item.Billede")" />
                              <div class="carousel-desc">
                                @GetValue("Item.Tekst")
                              </div>
                            </div>

Replies

 
Mikkel Ricky
Reply
This post has been marked as an answer

You can use the template tag ParagraphContainerSort for this. It's 1 for the first paragraph in a container.

But you should really use items to do stuff like this. See http://items.dynamicweb.dk/ for an example. The item types use for the slider (Carousel and Carousel_Item) and templates are available on Github: https://github.com/dynamicweb/itembasedmodules.

Best regards,
Mikkel 

Votes for this answer: 2

 

You must be logged in to post in the forum