问题描述
我正在SDL Tridion 2011 SP1中研究Dreamweaver TBB。
I am working on Dreamweaver TBBs in SDL Tridion 2011 SP1.
我不知道在Dreamweaver TBB中处理组件链接。
I am unaware of handling component links in Dreamweaver TBBs.
考虑我的组件名称为 A,它具有指向另一个组件 B的链接。
Consider my Component name is "A" which has link to another component "B".
组件A源看起来像这样:
Component A source looks like this:
<Content xmlns="Some UUID">
<Name xlink:type="simple" xlink:href="tcm:184-1897"
xmlns:xlink="http://www.w3.org/1999/xlink" xlink:title="B"></Name>
</Content>
组件B的来源是:
<Content xmlns="Some other UUID">
<first>first field</first>
<second>second field</second>
</Content>
我想编写一个DWT TBB,它可以从组件A访问链接的组件B中的字段。
I want to write a DWT TBB which can access the fields in the linked component B from Component A.
我想使用RenderComponentField再现方法。
I want to use RenderComponentField rendition method.
我是否需要添加任何扩展名,我才能在其上应用SiteEdit。
Do I need to add any extentions to it, will I be able apply SiteEdit on it.
请分享您的看法。
谢谢。
推荐答案
此主题有两个独立的问题:
- 如何在DWT中访问链接的组件中的字段?
- 如何使链接的组件中的字段在SiteEdit 2009中可编辑? em>
这是问题1的答案。我将为问题2提供单独的答案。
在Tridion对DWT模板中表达式的默认处理中,您只能访问包中Components的字段。因此,如果要访问组件B的字段,则必须编写一个C#TBB将该组件推入包中。
In Tridion's default handling of expressions in DWT templates you only have access to fields of Components that are in the package. So if you want to access the fields of Component B, you will have to write a C# TBB that pushes that Component into the Package.
一个示例C#片段:
var componentA = (Component) engine.GetObject(package.GetValue("Component.ID"));
var fieldsA = new ItemFields(componentA.Content, componentA.Schema);
var linkField = (ComponentLinkField) fieldsA["Name"];
var componentB = linkField.Value;
var itemB = package.CreateTridionItem(ContentType.Component, componentB);
package.PushItem("ComponentB", itemB);
如果将其放入C#片段TBB中并将其放入DWT之前的CT中,则可以在DWT中执行以下操作:
If you put this in a C# fragment TBB and drop it into your CT before the DWT, you can do this in your DWT:
@@ComponentB.Fields.first@@
您也可以使用Nuno的无需编写TBB即可访问此类字段:
Alternatively you can use Nuno's Dreamweaver Get eXtension (DGX) to access such fields without writing a TBB:
@@Get("Fields.Name.first")@@"/>
使用DGX的唯一缺点是您将需要在每个Tridion服务器上安装它。之后,您的DWT中将提供大量扩展功能。
The only downside to using the DGX is that you will need to install it on every Tridion server. After that, a heap of extended functionality is available in your DWTs.
这篇关于在Dreamweaver TBB中检索链接组件的值-使其成为SiteEditable的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!