I understand that out-of-the-box we can loop or iterate over arrays in DWT Template Building Blocks (TBBs) with the following.
<!-- TemplateBeginRepeat name="array_name" -->
<!-- template logic -->
<!-- TemplateEndRepeat -->
The documentation describes pre-defined package items as well as how to use them.
In summary we can use:
Component
to reference the current component when iterating over Components or Component PresentationsComponentTemplate
to reference current Component Template when iterating over Component Presentations (this would be at the page-level)Field
to reference current Field when iterating over Fields as well as Multi-Value fields.FieldPath
to get the full path to the iterated item. It's useful when usingTemplateRepeatIndex
within a nested loop as seen in The Tridion Practice Cookbook.*TemplateRepeatIndex
, the zero-based loop count.
We can do nested loops on Fields
in a given Component within a Components array loop, as well as by conditionally checking a specific field name when iterating over multivalue fields.
I've seen double look-ups by nesting DWT's syntax (e.g. @@Image_${TemplateRepeatIndex}@@
as described on Yet Another Tridion Blog).
Question(s)
To be sure, these are items or arrays/collections in a Compound Template's Package
, right (either there by default or placed by our code)?
Could we possibly "iterate" over separate items in a package?
For example if we have individual components in the Package
, could we "iterate" over them with something like @@Component${TemplateRepeatIndex}@@
?
- Component1
- Component2
- Component3
I see I can reference such an item within a loop, but everything I've seen suggests the following is not possible:
<!-- TemplateBeginRepeat name="@@Component${TemplateRepeatIndex}@@" -->
<!-- do something with @@Component${TemplateRepeatIndex}@@ -->
<!-- TemplateEndRepeat -->