Add Linked Components To Package

This generic template building block adds all linked components for a rendered page or component to the package. An end to the frustration of referencing linked component field values in your dreamweaver TBBS. Single value fields are added as a single component. Multi-valued fields are added as a component list, in order that you can iterate over them using a repeating region. 

Description

Do you wish you could write simple Dreamweaver syntax to directly refer to fields within linked components? This generic template building block enables you to do just that, by adding all linked components for a rendered page or component to the package. Single value fields are added as a single component. Multi-valued fields are added as a component list, in order that you can iterate over them using a repeating region.


When added to a compound Component Template the TBB will search all component link fields (including multimedia link fields) and add an item to the package for each (if there is a field value). The link field XML name is used as the package item key to enable you to refer to them in an intuitive way in your template. In the following example there is a component link field called RelatedLink:

Single value:
<a tridion:href="@@RelatedLink.ID@@" title="@@RelatedLink.Summary@@">@@RelatedLink.LinkText@@</a>

Multi value:
<!-- TemplateBeginRepeat name="RelatedLink" -->
<a tridion:href="@@ID@@" title="@@Summary@@">@@LinkText@@</a>
<!--TemplateEndRepeat -->

Metadata component link fields will also be added with the naming convention MetaData.<fieldname>

When added to a compound Page Template the TBB will search all page metadata component link fields and add them into the package also using the naming convention MetaData.<fieldname>

This template has a wide number of applications, from simply allowing access to a second level of field data in your component templates, to writing out lists of links (footer links, related links), to accessing translatable Page metadata components. 

No parameters are required for the TBB, nor does it require any specific structure or data to be defined in the CMS, or refer to any other C# functions or classes. Simply add the source code to your templating project, or upload the standalone dll assembly using TcmUploadAssembly.


Developer
:    Will Price
Company
License agreement
Tags
:    Template Builder,  Compound Templates
Version
:   1.0
Source
:   Yes

About the Author
Will Price
Principal Consultant

SDL WCM Solutions Division

Most Popular Building Blocks

These are the most popular Building Blocks. Did you already get them?