There are two separate questions in this topic:
- How to access fields from a linked Component in DWT?
- How to make fields from a linked Component editable in SiteEdit 2009?
This is the answer to question 1. I will provide a separate answer for question 2.
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.
A sample C# fragment:
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);
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@@
Alternatively you can use Nuno's Dreamweaver Get eXtension (DGX) to access such fields without writing a TBB:
@@Get("Fields.Name.first")@@"/>
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.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…