While developing modular templates you will always come across Dreamweaver templates. Since I’ve re-joined Tridion 3 months ago I learned a thing or two that are not documented and should benefit the community. So, here it is! My first blogpost.
Dreamweaver templates are rendered outside in. This means that the deepest repeating regeons and conditional blocks are rendered first, and that the mediator works its way from there to the top.
The result of this is that the following will not work. Both the TabIndex Package Item as the calls to RenderComponentField will return an empty string.
<!-- TemplateBeginRepeat name="Component.Fields.tabs" -->
@@Push("TabIndex", TemplateRepeatIndex)@@
<div id="tab@@TabIndex@@">
<!-- TemplateBeginRepeat name="Field.subtabs" -->
@@Push(“SubtabIndex”, TemplateRepeatIndex)@@
<div id="tab@@TabIndex@@_subtab@@SubtabIndex@@">
<h1>@@RenderComponentField(“tabs[${TabIndex}].subtabs[${SubtabIndex}].title”,
0)@@</h1>
<p class=”introduction”>
@@RenderComponentField(“tabs[${TabIndex}].subtabs[${SubtabIndex}].introduction”,
0)@@</p>
</div>
<!-- TemplateEndRepeat -->
</div>
<!-- TemplateEndRepeat -->
When the subtab is being rendered all mark-up in the outer repeating region is not touched yet and therefore the TabIndex Item is not pushed into the Package either.
You can work around this by using the FieldPath Item pushed into the package during runtime. This Item is (as far as I know) not documented but can be very useful.
While rendering the 3rd subtab of the second tab that path will be “tabs[1].subtab[2]”.
To solve this issue you can use the following approach:
@@RenderComponentField(FieldPath + “.title”, 0)@@