Setting meta tag descriptions and keywords under CakePHP 1.2
The following outlines a very simple method for setting meta tag descriptions and keywords in your views.
Add the following to your <head> section of your view/layout/default.ctp file.
Show Plain Text- <head>
- <?php } ?>
- <?php } ?>
- ...
- </head>
Then at the top of your view files you can set your specific meta descriptions and keywords.
Show Plain Text- <?php
- $this->pageTitle = "your unique page title");
- $this->set("meta_description", "your description goes here");
- $this->set("meta_keywords", "your,comma,separated,keywords,go,here");
- ?>
For pages dynamically generated you could simply set the meta description and keywords from your resultant array query. For example if my returned Post array had a metadesc and metakeys field I could set the description and keywords dynamically as follows:
Show Plain Text- <?php
- $this->pageTitle = $post['Post']['title']);
- $this->set("meta_description", $post['Post']['metadesc']);
- $this->set("meta_keywords", $post['Post']['metakeys']);
- ?>
Or use the html helper like this on your layout :D echo $html->meta('keywords',$meta_keywords); echo $html->meta('description',$meta_description);