Custom Page Titles
NAV IS OUTPUT
The Name of this section is "Custom Page Titles" but the <title> tag is using an element from the SectionMetaDescription Content Type.
Previously this required a Related Content Navigation object placed in the Page Layout to get an alternate layout from the SectionMetaDescription Content type. This is no longer required and instead we can add the following Handlebars code directly to the Page Layout.
{{#fulltext}}
{{#if (section field="Custom Title") }}
<title>{{section field="Custom Title"}}: {{publish element="Title"}} – Terminalfour University</title>
{{else}}
<title>{{sectionName}}: {{publish element="Title"}} – Terminalfour University</title>
{{/if}}
{{else}}
{{#if (section field="Custom Title") }}
<title>{{section field="Custom Title"}} – Terminalfour University</title>
{{else}}
<title>{{sectionName}} – Terminalfour University</title>
{{/if}}
{{/fulltext}}
How it works:
The fulltext Block level Handlebars helper allows us to know if we're viewing a fulltext of a page.
If we are, we check if the SectionMetaDescription has a field called "Custom Title" and it is set, so we can output that.
Note that because we are in a fulltext page we have access to the elements of the Content Type which is something that isn't possible using T4 tags. This allows us to use the publish Helper to output the Title element of the fulltext content type.
If we're not in a fulltext page we simply output the Custom Title if it exists, otherwise we output the section name.
Fulltext page example:
Check the <title>
tag of the fulltext content item below: