Quick TBB – Publish Schema/Template/Taxonomy config

On most projects I have worked on, at some point we have needed some Tridion uris in the web application, be it to load keywords from a taxonomy, or executing broker queries for items based on a certain schema ID, and return dynamic component presentations using a given Template uri. This article shows you a simple TBB to publish these config values.

Often on projects, in order to get results quickly, these uris get hard coded at first, and then perhaps moved into the appSettings section of web.config, to make them configurable across environments. Soon as more and more functionality is developed you end up with 10 or more uris in the config. Then you roll out multiple websites, each with their own web.config, which all need to be kept up to date. Things soon get out of hand…

A much better solution is to publish the configuration from the CMS itself – theres no need to keep everything updated manually across sites, and the differences between environments are managed automatically. Heres a TBB that does just this:

If you pop this into a Page Template, with file extension XML, you can publish a page with this template (no need to add any components to the page) and end up with something like the following:

Note that the logic in the TBB does some filtering so that not all items are added to the config. As you are only likely to need to want the uris of templates that have published dynamic components, or taxonomies that have been published it checks to see if a template or taxonomy has been published before adding it to the config. Also, we only add normal schemas, not parameter, metadata, multimedia etc.

All you need now is to create a simple class to read your config and provide uris to the web application based on the Key (which is derived from the item title).

This entry was posted in Development and templating, Tridion news by Will Price. Bookmark the permalink.

About Will Price

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.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>