In this tip you will learn about custom fields in Graffiti CMS.
Custom fields can be used in many ways, but in this tip, you will learn how to set a custom title for your pages. To create a custom field, in the admin panel, go to Site Options -> Custom Fields, let’s name it SEO-Title.
Once you have created the custom field, it will be available for each of your posts. Notice the screen captures below. There is a new tab, Custom Fields, click on that tab and you will see how you can specify a unique title for each post.
After you have setup a custom title add this code in your layout.view:
<title>
#if($macros.IsNotNull($post.Custom(“SEO-Title”)))
$post.Custom(“SEO-Title”)
#else
$title
#end
</title>
A slightly different way to accomplish the task is to make the change in post.view as follows:
#if($macros.IsNotNull($post.Custom(“SEO-Title”)))
#set($title = $post.Custom(“SEO-Title”))
#end