How To... Produce Dynamic Titles
Create dynamic section headers using the PATH tag.
Adapting the implementation of the PATH tag - normally used to create crumbtrails - is a neat method of creating dynamic sub-section titles for pages...
1. Build a PATH tag
This tag can happily sit inside an editable snippet amongst other tags. The essence of the tag is create a dynamic path back up through the site, but to limit the path to one item. Here is the Path tag applied to an H2, that will sit above an H1 and P tags.
%PATH(
direction=asc,
maxitems=1,
itemtemplate=dynamic_header)%
<h1>%TITLE%</h1>
<p>lorum ipsum...</p>
The Path tag has it's direction set to ascending as we want the path to go back up the site structure, and by limiting the maxitems value to 1, the system therefore retrieves the title of only one page - the one directly above the page this code has applied to.
2. The Itemtemplate snippet
The referenced itemtemplate - 'dynamic_header' takes this form...
<h2>%TITLE%</h2>
3. The Rendered Code
If we presume we are viewing a page called 'Apartments' in a section of the site called 'Housing Types', the rendered code will look like this:
RENDERED OUTPUT
<h2>Housing Types</h2>
<h1>Apartments</h1>
<p>Lorum ipsum... </p>