Sunday, March 12, 2006

Inserting a field value into the title tag of the layout


If you want to modify the contents of the < title/> tag in the layout dynamically and populate it with the value from a current item’s field, the following steps should be completed. 1. Create a rendering that will simply output the field value of the current item: <sc:text field="title" /> 2. Add the rendering definition inside of the < title/> tag: <title>
<sc:xslfile ID="pageTitle" runat="server" renderingid="{C954895B-655A-4C6C-8641-3B199CCDC2D9}" path="/xsl/Page Title.xslt" />
</title>
To make it more easy you can drop this rendering on your layout in the Layout Studio, then cut-paste it into the < title/> tag.

3 comments:

Anonymous said...

or using < title >< %# Sitecore.Context.Item["Title"] % >< /title > if you're too lazy to create a rendering ;-)

Unknown said...

thanks, Alexey. That's really much easier.

Anonymous said...

It's easier, but not really as architectural nice. Code in HTML...

:-)