Custom rendering
Customizing the rendering process involves manipulating the output produced by the rendering process, which typically combines a content item with a Template.
Customize rendering for the following reasons:
- You have a specific modification that you want to apply to all publishable content that is to be published. In this scenario, you could also create a Template Building Block and add it as the last Template Building Block in all your Templates. But especially if you have many different Templates, a custom renderer can be easier.
- You want to publish items of an item type that is currently not resolved or rendered. In this scenario, you would need to add a custom resolver to resolve this item type, a custom renderer to render it, and implement code on the receiving Content Delivery end to process the incoming content. The specifics of this scenario are not explored further here.
Creating a custom renderer consists of several steps.
- Step 1: creating a custom renderer class in .NET
-
To start, implement your business logic in a custom renderer class. This class implements the
IRendererinterface, found in the Tridion.ContentManager.Publishing.Rendering namespace. Create an assembly from this .NET class and add it to the Global Assembly Cache (GAC). - Step 2: extending Content Manager with your custom Renderer
-
Now that you have your custom Renderer set up, you can make it available to Content Manager by configuring it in the Content Manager configuration file on the Content Manager server, Tridion.ContentManager.config. To do this, do the following:
- On your Content Manager server, access the config\ subfolder of
%TRIDION_HOME%. - Open Tridion.ContentManager.config for editing.
- In this configuration file, locate the
<rendering>section, which contains a<renderers>section with a number ofaddelements, one for publishable item type. Here is one suchaddelement:<add type="Tridion.ContentManager.Publishing.Rendering.TemplateRenderer" assembly="Tridion.ContentManager.Publishing, Version=9.0.0.0, Culture=neutral, PublicKeyToken=360aac4d3354074b" />The
typeattribute indicates the type of items being rendered (Template in this case), as well as the class, and theassemblyattribute provides assembly information. - Add a new
addelement below the one already present. For example, to add aMyComponentRenderer.NET class, contained in an assembly calledMyTemplatingExtension, to the list of renderers, add the following newaddelement to the<renderers>section:<add type="MyComponentRenderer" assembly="MyTemplatingExtension, Version=1.0.0.0, Culture=neutral, PublicKeyToken=eb4399ad2323ad58"/>
- On your Content Manager server, access the config\ subfolder of
- Step 3: adding custom configuration (optional)
-
If your custom renderer class requires custom configuration, Tridion Sites expects to find such configuration in the same Tridion.ContentManager.config file, in the section named as specified in the code. To create and specify such a section, do the following:
- In the
<configSections>section at the top of the file, add asectionelement, provide a name, and set thetypeattribute to a class that can handle the contents of the section. For example, if the section will contain a simple named property, use the default .NET classSystem.Configuration.NameValueSectionHandler:<section name="My.Tridion.CustomRendering" type="System.Configuration.NameValueSectionHandler" /> - Next, at the bottom of the file, add a configuration section with the name you specified and fill it with content that the class you specified can handle. In this example, the section contains an
addelement with akeyand avalueattribute:<My.Tridion.CustomRendering> <add key="locale" value="ja-jp" /> </My.Tridion.CustomRendering>
- In the
- Step 4: Applying your changes
-
From your list of Windows Services, restart all Windows services that start with
Tridion Sites Content Manager. Also restart IIS and the SDL Tridion Sites Content Manager COM+ application. This applies your changes.