2

I am working on the Dreamweaver template building blocks and implementing SiteEdit for the page.

I am using SDL Tridion 2011 SP1 and Site Edit 2012 and Default Dream Weaver Templating.

My schema has a multi-value field of type "Component Link". My main component XML looks like this.

<Content xmlns="UUID">
    <link xlink:type="simple" xlink:href="tcm:202-8121"
          xmlns:xlink="http://www.w3.org/1999/xlink"></link>
    <link xlink:type="simple" xlink:href="tcm:202-8122"
          xmlns:xlink="http://www.w3.org/1999/xlink"></link>
</Content>

Linked component XML looks like this.

<Content xmlns="Some other UUID">
    <text>Hi all</text>
</Content>

My objective is to get the name of schema of the linked component and enable inline Editing for the the fields of the linked component too. I created a separate Component Template for the schema of the linked component with the URI tcm:202-8142-32.

I have written the DWT TBB for main component like this.

<!-- TemplateBeginRepeat name="Fields.link" -->
    <div>
        (FieldPath=@@FieldPath@@, TemplateRepeatIndex=@@TemplateRepeatIndex@@)
    </div>

    <!-- Not able to get the schema name of the linked component -->            
    @@RenderComponentPresentation(link, "tcm:202-8142-32")@@
<!-- TemplateEndRepeat -->

I am unable to loop through the component link field "link".

Then I changed the schema which allows only a single component link. When TBB written is as follows, things work fine:

@@RenderComponentPresentation(link, "tcm:202-8142-32")@@

I know that the problem lies in looping through the multiple component links.

Please suggest how to loop through the multiple component links and get the schema name of each linked component.

Widor
  • 13,003
  • 7
  • 42
  • 64
Patan
  • 17,073
  • 36
  • 124
  • 198
  • Can you have a look at the edits I've done to your previous questions and do the same here yourself. So: 1. properly indent your code and XML blocks (4 spaces at the start of the line, then 2 or 4 per indent level) to minimize the need for horizontal scrollbars, 2. mark each block with a language marker if Stack Overflow doesn't detect it correctly. If you don't know how to do these, just look at my previous edits or press the remarkably helpful ? button just above the text area where you enter/edit your question. – Frank van Puffelen May 24 '12 at 14:18

2 Answers2

1

I don't think it is possible for you to get the schema name using DWT. What you'll need to do is write a c# building block that extracts the values you are looking for, then puts this value into the package for you.

johnwinter
  • 3,624
  • 15
  • 24
  • I written one more Component Template to get the schema name of linked component. – Patan May 25 '12 at 04:25
  • When you're dealing with a multi-value field like this, writing a building block to push the value into the package means you have to add an unknown number of package variables, and manage the relationship with your link elements. I'd think it would be better to look at a function source implementation to extend the expression language. A good example of this can be found at http://www.sdltridionworld.com/community/extension_overview/dreamweaver_get_extension.aspx – Dominic Cronin May 26 '12 at 13:03
1

When you are looping over the values of a multi-value field (as you are doing here), the current value is available in a variable called Field. So if you just change your call to RenderComponentPresentation to refer to that, I think it should work:

<!-- TemplateBeginRepeat name="Fields.link" -->
    <!-- Not able to get the schema name of the linked component -->            
    @@RenderComponentPresentation(Field, "tcm:202-8142-32")@@
<!-- TemplateEndRepeat -->
Frank van Puffelen
  • 565,676
  • 79
  • 828
  • 807