Documentation Center

Implementing custom functions

You can use the TOM.NET API to create custom functions to use in Dreamweaver Templates.

Procedure

  1. Develop a custom class in C# using the TOM.NET API. For detailed information, refer to the TOM.NET API reference documentation.
  2. Strong-name the class and add it to the GAC (Global Assembly Cache) using the gacutil.exe command line tool.
  3. On the Content Manager server machine, open the file Tridion.ContentManager.config located in the config\ subfolder of %TRIDION_HOME%, in a plain-text or XML editor.
  4. Find the <tridion.templating> element (at the bottom of the file), and inside it, the <functionSources> element. Add a new element <functionSource> with a type attribute set to the class name and an assembly attribute set to the properties of the assembly (as a comma-separated list). For example:
    <tridion.templating>
    	<functionSources>
    		<functionSource type="Tridion.ContentManager.Templating.Expression.BuiltInFunctions" />
    		<functionSource type="MyCustomClass" assembly="MyCustomClass,
    			Version=1.0.0.0, Culture=neutral, PublicKeyToken=ddfc8957d6e5ee6b" />
    	</functionSources>
    </tridion.templating>
  5. Restart COM+ and Template Builder.

Results

You can now call functions in the new custom class from your Adobe Dreamweaver Template, if those functions have been marked as [TemplateCallable] in the C# code. For example, if a function Recalibrate that takes a single string parameter was so marked in the class, you can now write @@Recalibrate("foo")@@ in your Dreamweaver Template.

SDL Tridion World Article: The different levels of Compound Templating, parts 1 and 2

For a partner's perspective on templating in general and custom Dreamweaver functions in particular, refer to the SDL Tridion World article, courtesy of HintTech's Walter van der Heiden at these URLs: