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
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:
body field of your Componentvalue subfield of your body embeddable schemaFieldPath 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.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
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@@)