Huston Lopes
Huston Lopes

Reputation: 622

Looping component links in an Embedded field

We have a "component A" , which has a multivalue field of type 'embedded field'. The embedded field in turn has a multivalue field of type 'Component Link'.

This looks like: Component A -> Embedded Shcema Fields -> Component Links

How to iterate and access the fields of 'Component Links'in dreamweaver? Also the component field supports three different schemas and We want to check on these schema names in dreamweaver.

I found this post useful. But more details would be indeed great.

Upvotes: 1

Views: 2127

Answers (5)

David Forster
David Forster

Reputation: 1390

As Vikas previously mentioned, repeating over the multivalued component link field of a multivalued embedded schema field is relatively simple. Your DWT code should follow this form:

<!-- TemplateBeginRepeat name="XML Name of Embedded Schema Fields" -->
    <!-- TemplateBeginRepeat name="XML Name of multivalued Component Link field" -->
        @@Field@@  - Should write out the TCM ID of your linked component
    <!-- TemplateEndRepeat -->
<!-- TemplateEndRepeat -->

You can not, however, access the fields or schema details of these components with "out of the box" Dreamweaver Templates.

You can:

  1. install the Dreamweaver Get eXtension on your Content Manager server, which will allow you to retrieve fields of linked components (amongst other things) using the @@Get(...)@@ syntax
  2. Use the "Get Linked Components" .Net TBB from the Generic SDL Tridion 2011 Template Building Blocks before your Dreamweaver Template, which will place the linked components into the templating package so that you can iterate over them directly
  3. Write your own .Net TBB to handle your specific business logic related to these links and output html (not recommended) or a named package item, items or array of items that you can handle from your DWT.
  4. Call another (nested) component template from your DWT with @@RenderComponentPresentation(Field, "tcm:x-xx-32")@@
  5. Any combination of the above

Upvotes: 2

Meenakshi
Meenakshi

Reputation: 599

Please try using below code:

          <!-- TemplateBeginRepeat name="paragraphs" -->
               <!-- TemplateBeginRepeat name="Internal_Link" -->
                 <!-- TemplateBeginIf cond = "Internal_Link != ''" -->
                    <p> @@Component.ID@@ </p>
                 <!-- TemplateEndIf -->
               <!-- TemplateEndRepeat -->
         <!-- TemplateEndRepeat -->

To check for zeroth component you can use below code:

          <!-- TemplateBeginRepeat name="paragraphs0.Internal_Link" -->

Upvotes: 1

vikas kumar
vikas kumar

Reputation: 2444

You can easily iterate through component link of multi value embedded field but there is no direct way to get component link values, you have to use either dwt extension, or .net tbb. There are some available on sdltridionworld.com.

I did this earlier with nested template. You may also try nested/sub template from your main dwt tbb based on schema of component link field component in the loop.

Also I would suggest to use razor templates.

Upvotes: 3

Arjen Stobbe
Arjen Stobbe

Reputation: 1684

You can iterate through the multi-value field paragraph in the embedded schema field paragraphs as follows:

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

    <h2>@@Field.header@@ (@@TemplateRepeatIndex@@)</h2>
    <!-- TemplateBeginRepeat name="Field.paragraph" -->
        <p>@@Field@@</p>
    <!-- TemplateEndRepeat -->

<!-- TemplateEndRepeat -->

Upvotes: 2

Frank van Puffelen
Frank van Puffelen

Reputation: 600006

Have a look at these questions:

And this page from the Tridion practice cookbook:

They cover the most common problems you may have with accessing fields in a DWT.

If these don't answer your question, update your question with:

  1. the relevant XML fragment of your Component
  2. the DWT fragment showing what you already tried

Upvotes: 4

Related Questions