How to handle nested repeating regions in Dreamweaver TBBs in SDL Tridion 2011 SP1

后端 未结 5 558
清酒与你
清酒与你 2020-12-03 19:03

I am working on DWT TBB in SDL Tridion 2011 SP1.

I have a embedded field \"body\" which is multivalued. In this embedded field I have one more simple Text field \"va

5条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-12-03 19:29

    The Tridion practice page that Neil referred to is a good reference. But that page shows how to generically iterate over all embedded fields. In cases where you know the field name, things get a bit easier. In you case, this is all that is needed in your DWT:

    
        
            
    @@RenderComponentField(FieldPath+".value", TemplateRepeatIndex)@@

    Line by line:

    1. Iterate over the values of the body field of your Component
    2. Iterate over the values of the value subfield of your body embeddable schema
    3. At this stage the FieldPath refers to the current body value, so body[0], body[1], etc. and TemplateRepeatIndex is the index of the current value. So we can construct the correct RenderComponentField call with this knowledge.

    Example

    I have a Component with two body fields, each with two value fields. So the XML is:

    
        
            body1.value1
            body1.value2
        
        
            body2.value1
            body2.value2
        
    
    

    The output from the above DWT on this Component is:

    body1.value1
    body1.value2
    body2.value1
    body2.value2

    Debugging these situations

    Many people have problems writing constructs like these. I am no exception, I have just found that I can get most cases working by knowing that the crucial variables are: Field, FieldPath and TemplateRepeatIndex. When in doubt, simply embed this fragment into your DWT inside every TemplateBeginRepeat.

    (FieldPath=@@FieldPath@@, TemplateRepeatIndex=@@TemplateRepeatIndex@@)
    

提交回复
热议问题