Default Finish Actions Revisited: The Cleanup Template

CT

Here is what the  SDL Live documentation says for Cleanup Template:

” This default Template Building Block, which can be used in any Compound Template, removes all artifacts from the item named Output that are produced by the template engine. The templating engine may sometimes insert special markers or tags that assist it in providing certain functionality and this template ensures that these are all removed at the end of the render process “

So, we must ask at least 2 questions here: 

  1.  What are those ‘artifacts‘, ‘special markers‘ and ‘tags‘ referred to in above description ?
  2.  what are the functionalities ( design behaviour/ deploy behaviour / Runtime Behaviour / …. ) referred to when the documentation says: ‘ that assist it in providing certain functionality ‘ ?

Well… let’s look at the first part of the above question. The artifacts or the markers/tags referred are the TCDL tags generated by the templating engine in the render process.  Not all TCDL tags are cleaned up by the Cleanup Template. It will be more appropriate to say that Not all TCDL tags are the responsibility of Cleanup Template. Some TCDL tags are the responsibility of Link Resolver Template ( also present in Default Finish Actions ).

Specifically, the Cleanup Template cleans up below TCDL tags depending on the context ( Preview or Publish )

  1. When Previewing ( a Page )  / when running in Template Builder
    <tcdl:ComponentPresentations>,<tcdl:ComponentField>,<tcdl:Field> and <tcdl:FieldValue>
  2. When publishing :
    <tcdl:ComponentField>,<tcdl:Field> and <tcdl:FieldValue>

For any Component Presentations  inserted in a page, the corresponding HTML is wrapped around the TCDL tags <tcdl:ComponentPresentation />.  for example:

<tcdl:ComponentPresentation type="Embedded" componentURI="tcm:218-144492"
      templateURI="tcm:218-149517-32" 
      xmlns:tcdl="http://www.tridion.com/ContentDelivery/5.3/TCDL " >  
           <!-- HTML BEGINS -->     .....     <!-- HTML ENDS -->
</tcdl:ComponentPresentation>

The Cleanup Template simply removes  such <tcdl:… /> tags when previewing and what remains is the HTML wrapped inside such TCDL tags.

So The below HTML,

<tcdl:ComponentPresentation type="Embedded" componentURI="tcm:218-144492"
      templateURI="tcm:218-149517-32" 
      xmlns:tcdl="http://www.tridion.com/ContentDelivery/5.3/TCDL " >  
           <!-- HTML BEGINS -->  ...   <!-- HTML ENDS -->
</tcdl:ComponentPresentation>

after being processed by Cleanup template , in Preview mode ,  will become:

<!-- HTML BEGINS --> ....  <!-- HTML ENDS -->  

Simply, we can say,  the TCDL tags are stripped out.

Why the Cleanup of such TCDL tags ?

Cleanup while Previewing : 

It seems logical that when we preview ,say a page , then we would like to see the resulting HTML generated after processing of the templates. The resulting HTML should be as close as possible to standard HTML tags. In such an attempt  any intermediaries/temporary tags injected into the Output by Tridion , which will make no sense if present in the HTML being previewed , are cleaned up by the Cleanup Template.

Do comment on what you think as  possible reasons for  Cleanup.

Note that there are other templates as well in Default Finish Actions, like the Link Resolver TBB, which also does  some kind of  substitution/replacement of TCDL tags with  corresponding HTML in Preview mode , again in an attempt to be as close as possible to the standard HTML tags.

So, the following DWT sample code

<a tridion:href="@@Component.Fields.ProductLink@@" class="productSection"
   target="_blank" title="@@Component.Fields.ProductLinkText@@"> 
   @@Component.Fields.ProductLinkText@@
</a>

after being processed by Link Resolver TBB will become ( In Preview mode ):

<a href=”CME_PREVIEW_URL#id=tcm:123-654674” class=”ProductSection” title=”Products” target=”_blank”></a>

Cleanup when Publishing :

Coming back to Cleanup template, Lets see what happens when we publish a page. In publish mode the tags  ( ComponentField, Field, FieldValue) are only cleaned up by the Cleanup Template.( As you may have noticed, these tags are the one pertaining to SiteEdit / Experience Manager implementation ). Any other TCDL tags , if present, are NOT cleaned up.

The TCDL tags left uncleaned during publishing are meant to be processed later during deploy/ runtime processing stages. We will consider an example of processing done during each of these stages .

Deploy  Stage processing Example:

The cd_deployer_conf.xml file is crucial in processing the incoming content  which was published from Content Manager. This config file contains an element  <TCDLEngine> which specifies the custom configuration for the Tridion’s Content Delivery Language(TCDL ) Engine.  Based on the settings defined in this element, the Content Delivery transforms the TCDL into corresponding  JSP , Asp.Net code.

For Processing Pages, below settings are defined in the config file: cd_deployer_conf.xml

<Module Type=”PageDeployClass=”com.tridion.deployer.modules.PageDeploy“>
<!– The transformer enables the TCDL Engine –>
<Transformer Class=”com.tridion.deployer.TCDLTransformer“/>
</Module>

And, to transform the TCDL tags to Asp.Net based Custom Server Controls, below are the settings:

<TCDLEngine>
<Properties>
<Property Name=”tcdl.dotnet.styleValue=”controls“/>
<Property Name=”tcdl.jsp.styleValue=”tags” />
</TCDLEngine>
</Properties>

Let us take the example of <tcdl:ComponentPresentation  /> tag which wasn’t cleaned up when publishing.

 

CASE I: Component Presentation inserted in Page is using Embeded CT

At the deployer stage, the Transformer specified processes this tag and replaces it with the Contents of the tag. The Contents of the tag is the actual HTML. As a result, the final page deployed on the CDA server  does not has any <tcdl:ComponentPresentation /> tags.

CASE II: Component Presentation inserted in Page is using Dynamic CT

At the deployer stage, the Transformer specified processes this tag and replaces it with the Asp.Net based Custom Server Control tag. Particularly, in this case of a Dynamic CT, The Custom Server Control tag  substituted in place of TCDL tags will be:

<tridion:ComponentPresentation runat="server"  PageUri="tcm:25-15647-64" 
         ComponentUri="tcm:25-15655" TemplateUri="tcm:25-13749-32" />

Runtime processing example:

In addition to the Dynamic Component Presentation(DCP)  example just seen above, TCDL  Link tags which link to Binaries, Component, Page etc… are also rendered at runtime at server side, when a user requests a page through browser.

You must have written below line of code ( or copy pasted, which we developers love to do some times) , thereby  using the attribute tridion:href in your DWTs, when  linking internally to other Content Manager items, such as:

<a tridion:href="@@Component.Fields.ProductLink@@" class="productSection">
    @@Component.Fields.ProductLinkText@@
</a>

Such Tridion Specific tags/attributes as tridion:href are resolved by the Link Resolver TBB , first to TCDL Link tag such as :

<tcdl:Link type="ComponentPageURI="tcm:123-250233-64" 
      ComponentURI="tcm:123-654674" TemplateURI="tcm:0-0-0" 
      AddAnchor="false" LinkText="Product" LinkAttributes=" class="productSection" 
      title="Product" " TextOnFail="true" />

After that, these TCDL Tags, when processed by the Deployer are converted either to inline Asp.Net code or to Asp.Net based custom server control tags, depending on the settings defined in deployer config : cd_deployer_conf.xml, for example, to make tridion transform the above TCDL tags into Asp.Net based Custom Server Control tags, Place below settings in the deployer config: 

<TCDLEngine>
<Properties>
<Property Name=”tcdl.dotnet.styleValue=”controls“/>
<Property Name=”tcdl.jsp.styleValue=”tags” />
</Properties>
</TCDLEngine>

Therefore, the above TCDL Link tag will get converted to below Asp.Net code:

<tridion:ComponentLink runat="server" PageURI="tcm:123-250233-64" .... />

Finally, it is these Asp.Net Custom Server Control tags ( inline code as well, if any) which are processed and thus rendered  at run time. Refer to  this blog post which covers this topic in full detail with examples.

Lastly, refer to this blog post to understand the Asp.Net Custom Server Controls generated by Tridion ( You can also call them as Tridion’s Custom Web Controls ).

Hope you enjoyed this post. Suggestions to further improve are most welcome.

 


9 thoughts on “Default Finish Actions Revisited: The Cleanup Template

  1. On a other note, you may look into link resolving in DD4T (maybe DXA as well) where you are controlling it from delivery end (presentation server) completely to reduce complexities. Basic concept (tcdl–>tridion–>anchor) that is quite same i guess. :)

    Like

  2. I thought Deployer just deploys the package. Now I corrected myself to Deployer processes and deploys the package as it seems. Thanks for sharing !!!

    Like

  3. When using the Dynamic CT in pages, the Page on our server has tridion:ComponentPresentation tag. So can you please tell me how this tag is converted to final HTML ? the HTML I wrote in DWT is only getting displayed. how does the tag got the HTML i wrote in DWT ? The DWT is present in content Manager I believe ? how is it fetching html then ?

    Like

    1. @ D Simmons : When using a dynamic CT, the Final HTML is rendered by Querying the Broker Database. The tridion:ComponentPresentation tag generated in this case, actually makes the Query to broker db at runtime to get and display the resulting HTML.

      The Content Manager db is NOT queried here.

      Like

      1. Great !! and a very well pointed out technicality about the Dynamic CT. I did found the HTML presentation stored in broker db as well. Thanks a lot for sharing such an info.

        Like

  4. Great article Nitesh. I have been always interested in understanding a programming Construct fully rather than jumping directly to technical implementations.

    The way you explained and then discussed a basic ( and necessary ) technical things of the Cleanup template is just superb. I feel like now I understand a lot more on Cleanups being done in Tridion’s rendering process.

    Like

  5. This is really a great information you have shared!. The online docs merely give a definition which wasn’t helpful to understand the inner workings and technical of this Template.

    I do feel I now have a better understanding of the Default Templates of Tridion. It is the inner working details & Technical insight you have shared that make this article a Great one!! Keep sharing.

    Like

  6. very well explained post on workings of cleanup template. Too much workings and processing is there behind this seemingly simple template! and you have beautifully explored such workings.

    Once again a marvelous post. Bookmarked now.

    Like

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s