Looping through the multiple component links to get the schema name of the linked component in Dreamweaver TBB in SDL Tridion 2011

余生长醉 提交于 2019-12-10 10:41:34

问题


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.


回答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 -->



回答2:


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.



来源:https://stackoverflow.com/questions/10738405/looping-through-the-multiple-component-links-to-get-the-schema-name-of-the-linke

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!