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.

A much needed update (December 2009) to this TBB now fixes the following:

  • Updated for SDL Tridion 2009
  • Fixed bug where SiteEdit and other TBBs would break as Component was no longer the first component item in the package
  • Fixed bug where Component metadata links were not processed
  • Now finds linked components within embedded fields
  • Added processing for flash - now Flash links are added as binaries into the package along with the publish url in the format -flashfieldname-Url - this solves the annoyance where you cannot make a reference to a flash item url in your Dreamweaver TBB or get the flash binary published using Default Finish Actions.

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
:   2.0
Source
:   Yes

About the Author
Will Price
Principal Consultant

Will is a seasoned web application consultant having worked on web projects for clients all over the world for the last 14 years. He has a deep technical and functional understanding of SDL Tridion solutions from his 6+ years working at SDL as a Principal Consultant in Amsterdam. Since 2012 he has been working freelance and continues to be involved in SDL Tridion projects.

W.P. Consulting

Most Popular Building Blocks

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