How to access componentlink field names in third level? I have a schema which contains a field as embeddable schema, in that embeddable schema, I have a component link which is derived from another schema. How can i retrieve the field of that schema?
-
1Could you please specify what API you want to use and rename your question accordingly – Andrey Marchuk Jun 01 '12 at 06:32
4 Answers
It really depends on the purpose of those field(s), perhaps you could provide some more information?
Another option not mentioned here is to write your own C# building block to add these 3rd level components to your package. By doing so you make it a lot simpler to work with them in your DWT layout.
For example if your third-level items are used to generate a list of office locations, you could write a C# block to obtain all the relevant office location components and add them to your package as a component list 'Locations' all you would simply need to do in your DWT is loop those items and provide the display you need.
Personally I don't like to use / add functions into DWT, I try to keep it as simple as possible, again if you can provide more information about your scenario that would generate a better answer for you from the community.

- 3,624
- 15
- 24
As far as I know, you need a special DWT TBB to get some control over your embedded/componentlinks. Maybe you could use Nuno's Get Extensions ? http://www.sdltridionworld.com/community/extension_overview/dreamweaver_get_extension.aspx Or use Razor Mediator, perhaps: http://www.sdltridionworld.com/community/2011_extensions/razormediator.aspx

- 579
- 2
- 10
-
If you're using DWTs then I'd definitely consider the DW Get extension. – Jeremy Grand-Scrutton Jun 01 '12 at 07:55
To prevent having to use either the DGX (as MDa suggests) or write a C# TBB (as John Winter suggests), you can also simply call RenderComponentPresentation
to render the linked Component with the template that you want to use.
<!-- TemplateBeginRepeat name="Component.Fields.LinkFieldName" -->
@@RenderComponentPresentation(Field, "tcm:1-23-32")@@
<!-- TemplateEndRepeat -->
Where tcm:1-23-32
it the TCM URI of a Component Template that simply renders the name of the Component as a hyperlink. Inside the DWT that you use in tcm:1-23-32
you can then simply refer to all fields and properties of the linked Component like Component.Title
, Component.Fields.Field1
, etc.
Note that the relevant topics have been covered already in these other questions/answers:
- rendering the title of a linked component - Looping through the multiple component links to get the schema name of the linked component in Dreamweaver TBB in SDL Tridion 2011
- getting values of a linked component - Retrieving values of a linked component in Dreamweaver TBB - and making it SiteEditable
- handling nested embedded schemas - How to handle nested repeating regions in Dreamweaver TBBs in SDL Tridion 2011 SP1
If somehow these did not help you enough, I suggest you post the XML of your Component and the DWT that you're trying to make work.

- 1
- 1

- 565,676
- 79
- 828
- 807
Here a quick sample using C#
Session session = engine.GetSession();
Item componentItem = package.GetByName(Package.ComponentName);
Component component = new Component(new TcmUri(componentItem.GetValue("ID")), session);
ItemFields itemFields = new ItemFields(component.Content, component.Schema);
IEnumerable<ComponentLinkField> ie = itemFields.OfType<EmbeddedSchemaField>().OfType<ComponentLinkField>();
for (IEnumerator<ComponentLinkField> e = ie.GetEnumerator(); e.MoveNext(); ) {
Component linkedComponent = e.Current.Value;
}
By using Linq you can navigate through the fields structure really quick and get results. It will give you the Component Links in the third level, of course you can use the same to go deeper in the structure.

- 393
- 1
- 4