0

Inside a rendering variant I added a template. Inside that I want a for each loop. Can anyone please suggest if it's feasible. Sitecore 9.2

  • if you mean for each inside a nvelocity template you can use: #foreach($child in $item.Children) $child.Name #end – Vlad Iobagiu Sep 14 at 19:38
2

As you mention 9.2 we can assume this is a NVelocity template. As Vlad mentioned, you can use a foreach loop there as shown here: http://people.apache.org/~henning/velocity/html/ch05s04.html

<ul>
  #foreach( $product in $allProducts )
    <li>$product</li>
  #end
</ul>

Note however that 9.2 is the last version that support NVelocity - and it usually is not such a good idea to put too much logic inside a NVelocity template.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.