9

I'm trying to implement Condition Sentence for nested multiple embeddable link field in the DW Tempate.

But in the 1st Repeat sentence, I can't judge if the 2nd embeddable link field is empty or not.

could you give me any ideas for this?

Thank you very much in advance.

My code is below

<!-- TemplateBeginRepeat name="Component.Fields.Embeddable_Block_Items" -->

<!-- TemplateBeginIf cond="Field.Embeddable_Image_Link_Items != '' || Field.Description != ''" -->
<!-- TemplateBeginIf cond="Field.Description != ''" -->
This should be worked.
<!-- TemplateEndIf -->

<!-- TemplateBeginRepeat  name="Field.Embeddable_Image_Link_Items" -->
This should worked ${TemplateRepeatIndex}
<!-- TemplateEndRepeat -->
<!-- TemplateEndIf -->
<!-- TemplateEndRepeat -->

enter image description here

  • 3
    Hi Naoki, the forums are closed to a lot of people so please could you add the detail here? It would also increase your chances of getting more answers! – Dave Houlker Apr 9 '13 at 7:31
  • 1
    Hi! Dave. Thank you very much for your advice. I edit my topic. – Naoki Apr 9 '13 at 8:38
4

How to handle nested repeating regions has been explained by Frank van Puffelen on Stack Overflow before here: How to handle nested repeating regions in Dreamweaver TBBs

Most of the time the trick is in knowing what variables to use where. There are a couple of crucial variables that can help you here, being: Field, FieldPath and TemplateRepeatIndex. You can simply add the following fragment in your DWT (inside every TemplateBeginRepeat) while you are building/debugging your Template.

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

Also note that when nesting repeating regions, there is only one TemplateRepeatIndex, that of the current region you are in. More on that topic can also be found on Tridion Practice - Iterate over multi-value multi-level embedded fields in DWT

| improve this answer | |
  • Excellent tip Bart! It would appear however that the poster's problem is not accessing outer loop variables but testing if a multivalue embedded field has any values. I'll agree that the question title is misleading... – Bjørn van Dommelen Apr 9 '13 at 11:46
4

I'll assume "Embeddable_Image_Link_Items" is a multivalue embedded field? In that case you cannot directly test if the field has content in a DWT.

Your can either use a "hack" in the DWT to assess if the field has any content by using a template repeat region:
<!-- TemplateBeginRepeat name="Field.Embeddable_Image_Link_Items" -->
<!-- TemplateBeginIf cond="TemplateRepeatIndex = 0" -->
Field has value (one or more)
<!-- TemplateEndIf -->
<!-- TemplateEndRepeat -->

Or if your multivalue embedded field has mandatory subfields you can use
<!-- TemplateBeginIf cond="Field.Embeddable_Image_Link_Items.subfield" -->
<!-- TemplateEndIf -->

which will evaluate to true if any of the embedded fields have a value for "subfield".

Or you need to create a C# fragment or assembly TBB to determine if the field has value and push this into a separate package variable which you evaluate in your DWT.
<!-- TemplateBeginIf cond="Embeddable_Image_Link_Items_HasValues" -->
Field has value (one or more)
<!-- TemplateEndIf -->

| improve this answer | |

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.