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’:
- 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)
- In CustomTemplates.ascx, create a RenderingTemplate with the ID of ‘ImageCustomTemplate’. Here is an example:
[]
- Add a RichImageField to your page layout, assign the FieldName and give it a DisplayTemplateName of ImageCustomTemplate:
- Restart the website application/application pool.
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