Developing Tridion 2011 .Net component templates

Recently i had the opportunity to develop component templates for a Tridion 2011 implementation. In this article I want to share my thought on the new templating features, provide quick tips and wrap up with some templating limitations that should be addressed in future versions of Tridion.

My previous Tridion component template development experience is all based on VBscript and the templating features from Tridion 5.3. Since I have plenty experience with .Net development I was confident the switch to Tridion 2011 template development would be a smooth one. It’s worth mentioning that I only developed component templates since the implementation used a dynamic publishing model (only component presentation xml is published to the database). The overall experience with the new templating features was very positive, the biggest improvements that I would like to point out:

  • Better productivity because of the ability to work with Visual Studio, a professional IDE which offers syntax highlighting, code completion and other nifty tools that increase developer productivity.
  • Faster bug fixing because of remote debugging and the logging functionality offered by the Tridion libraries.

The overall improvement of the template development experience has been quite substantial for me, being able to use a full fletched IDE and having decent debugging options makes a world of difference to me and my productivity as a developer.

Tridion .Net templating quick tips

When getting started with .Net template development there are some things you should look at, as they will have a positive effect on productivity and possibly save some frustration:

  • If you have the possibility, install Visual Studio on the same machine as the Tridion Content Manager Server. This allows for easier remote debugging of you templates without the risk of network/domain component causing issues and leaving you unable to use remote debugging. If you are unable to get remote debugging working on the customer network and you cannot install Visual Studio on the Tridion Content Manager, consider setting up a separate development environment where you can, cause debugging will boost productivity greatly. There is documentation on how to get remote debugging working on SDL live content.
  • Download the AssemblyUploader2 plugin for Visual Studio, this plugin allows for fast uploading of dll files into Tridion, having this plugin will save you a lot of manual and repetitive upload tasks.
  • Making the switch from VBscript to .Net I needed to get familiar with the new TOM.Net API. There are two things which make this process easier and faster. The most important thing to obtain the Tridion 2011 SP1 TOM.Net API documentation provided by Tridion. Use the Visual Studio object browser to quickly nagivate the Tridion libraries and see what functionality they expose.

Tridion .Net templating limitations

As stated in the introduction, there are some limitations to the Tridion .Net template development which I encountered during the project.

  • The most noticeable for me is the limited support for automated testing. Tridion classes used for templating are not testable making it harder to isolate code for testing. During training at Tridion the trainer did mention that Tridon will look at this for future versions.
  • A limitation worth mentioning is that all templating code has to be uploaded to Tridion in a single dll file, so all the code has to be maintained within one Visual Studio project. I found this out the hard way: Template execution failed when I referenced a second project which contained utility/support classes while both dll files where unloaded into Tridion correctly. This limitation can be frustrating when you want to reuse code from utility/support classes which reside within a different project. Fortunately there is a workaround for this limitation. Visual Studio offers the choice to add classes from a different project to the current project as a link. This way you can use the code from other projects within you templating project without duplicating the code.

Wrapping up

Tridion still supports VBscript templates, the reason is simple: upgrading Tridion should not break any existing templates and implementations. Even though VBscript is not officially deprecated I strongly recommend making the switch to .Net development for your next template development project. The reason is simple, the switch has to be made sometime, better make it soon and start seeing the benefits of the new .Net template development features for yourself.

4 thoughts on “Developing Tridion 2011 .Net component templates

  1. Hi Oskar,

    Nice to see a new face blogging about SDL Tridion. Tom.Net was actually introduced in SDL Tridion version 5.3, that said I know a lot of customers that started with 5.3 and went down the route of using VB templates.

    I see your blog also focuses a lot on .NET MVC, there is a razor mediator available for Tridion, which I think you’ll find interesting. You can download it free from Happy template developing !

    • Hi John,

      The Razor mediator came up during a Tridion training recently, but since I do not work with pages and page templates (only component presentation xml is published to the database) at this time I have not yet looked into the mediators. When I get into contact with pages I will take a look at the Razor mediator, thanks for pointing it out.

  2. Another thing that might interest you is Dynamic Delivery for Tridion (DD4T). It is a set of templates and libraries that expose the Tridion object model directly in a web application. It contains out of the box connectors to ASP.NET MVC 3. In my experience, this further increases the productivity of developers, plus it paves the way for automated unit testing.

    • Hi Quirijn,

      Thanks for the tip, this is the first time I hear about DD4T. I will definitely check it out first chance I get, thanks for pointing it out.

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=""> <strike> <strong>