Title, description and keywords in CakePHP 1.3

We develop many of our web apps in CakePHP 1.3, which is a really great tool but sometimes suffers from sections missing in the manual. This is not so much a how-to, but more of a question as to whether there is a better way, perhaps built in to 1.3?

Setting a title is no problem, by outputting $title_for_layout in your layout and setting in your controller (or page view) with:

$this->set('title_for_layout', 'Your page title');

The approach for Meta details in the manual suggests:

echo $html->meta(
    'enter any meta keyword here'

echo $html->meta(
    'enter any meta description here'


Source: http://book.cakephp.org/view/1438/meta

We take time over our SEO and this doesn’t seem as ideal as the title, as the description should be unique and descriptive as per the title. We looked to use the same basis as title and have now added:

if(isset($description_for_layout)){ echo ""; }
if(isset($keywords_for_layout)){ echo ""; }

Allowing for easy use with the title in a little ‘SEO block’, to be used in either a controller or view (e.g. for pages):

$this->set('title_for_layout', 'My page title');
$this->set('description_for_layout', 'My page description');
$this->set('keywords_for_layout', 'Keyword 1, Keyword 2, Keyword 3');

If you know of a better ‘CAKE’ way, then do please let us know.

Grow your digital and realise your potential