MOSS 2007: Creating named templates

Named templates allow for templating the output of a supporting field control from a centralised template. It’s not necessarily meant for html reuse on page layouts, but it would do the job. You’d really only want to use it if you had complex html being outputted by an image/text field and it the same html was used across multiple pages.

Like I mentioned in a previous post, field templates (named or inline) will not give you property-level access to content; meaning you can’t access the alternate text or the url of a link by itself. With that warning aside, let’s create a named template.

To create a named template called ‘ImageCustomTemplate’:

  1. Create a file named CustomTemplates.ascx in c:\Program Files\Common Files\Microsoft Shared\web server extensions\12\TEMPLATE\CONTROLTEMPLATES (you can call the ascx file anything you want, as long as it is .ascx)
  2. In CustomTemplates.ascx, create a RenderingTemplate with the ID of ‘ImageCustomTemplate’. Here is an example:
    
    
    
     
      []
     
    
    
  3. Add a RichImageField to your page layout, assign the FieldName and give it a DisplayTemplateName of ImageCustomTemplate:
    
    
  4. Restart the website application/application pool.
This entry was posted in Uncategorized. Bookmark the permalink.

One Response to MOSS 2007: Creating named templates

  1. The_Derro says:

    Yo Cozmo!.. I think you should have stuck to selling Knives to the innocent citizens of Bowral and the boarding house :) We need to catch up and have a drink my friend.. the_derro at scarlett dot id dot au

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 )

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