8

I'M trying to implement DW Template using the Useful TBB("Get Linked Component") found the following URL. https://sdltridionworld.com/community/2011_extensions/generic-2011-tbbs.aspx

This TBB have the following function as one of all.

If Multi(each) Embedded field have component link field (also multiple value field), it pushs some Component arrays (which is consist of component link field values) to the package as the key of "[embedded field name][Index].[Component link field name] (ie: "embeddable_items1.product_item" "embeddable_items2.product_item" "embeddable_items3.product_item")

The problem is when you implement repeat structure in the DW Template, how can I get the TemplateRepeatIndex in the repeat condition?

I tried the following code, but an error has occured.

<!-- TemplateBeginRepeat name="Embeddable_Faq_List_Items${TemplateRepeatIndex}.Faq_Item" -->
       [some code here]
<!-- TemplateEndRepeat -->

Could you give me any idea for this?

Thank you very much in advance.

  • 1
    What error are you exactly getting, could you edit the question and update it with the specific error message and details? – Bart Koopman Mar 18 '13 at 10:49
6

It is not possible to use the TemplateRepeatIndex inside a repeating or conditional statement as you are trying to do.

In my opinion you are pushing the boundaries of what the Tridion Dreamweaver templating language is capable of handling elegantly in terms of nested looping and embedded fields. You have several options:

  1. Rework your content model to avoid using multivalue embedded multivalue component link fields (perhaps by using a component link instead of embedded schema) - Whether this makes sense or not should be evaluated from an Editorial point of view, rather than being driven by technical necessity however

  2. Use a more flexible templating language, like Razor, or XSLT

  3. Abstract the generation of HTML for your linked faq components into a separate (embedded) Component Template, and call this from within a double loop:

Sample

<!-- TemplateBeginRepeat name="Embeddable_Faq_List_Items" -->
  <!-- TemplateBeginRepeat name="Field.Faq_Item" -->
    @@RenderComponentPresentation(Field,FaqItemEmbeddedComponentTemplateUri)@@
  <!-- TemplateEndRepeat -->
<!-- TemplateEndRepeat -->

Note that you will need to push into the package a variable called FaqItemEmbeddedComponentTemplateUri which contains the Uri of the embedded CT.

3

It looks like you are looking for this:-

IteratingOverMultivalueEmbeddedFields, this is the best example wrote on tridion-pratice page.

Sample:

<!-- TemplateBeginRepeat name="Component.Fields" -->
    @@Field.Name@@
    <!-- TemplateBeginRepeat name="Field.Values" -->
        <!-- TemplateBeginIf cond="Field.ContentType = 'text/plain'" -->
            @@RenderComponentField(FieldPath, TemplateRepeatIndex)@@
        <!-- TemplateEndIf -->
        <!-- TemplateBeginIf cond="Field.ContentType = 'tridion/field'" -->       
            <!-- TemplateBeginRepeat name="Field.Fields" -->         
                @@Field.Name@@         
                <!-- TemplateBeginRepeat name="Field.Values" -->          
                    @@RenderComponentField(FieldPath, TemplateRepeatIndex)@@                
                <!-- TemplateEndRepeat -->       
            <!-- TemplateEndRepeat -->     
        <!-- TemplateEndIf -->   
    <!-- TemplateEndRepeat -->
<!-- TemplateEndRepeat -->

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.