I just noticed that several people are searching for a phrases like "cakephp home change page title" or "page title cakephp" and landing up here. I am sure they must be returning disappointed - so this is an quick tip for them
Update:For CakePHP 1.3 the syntax has changed and it is now
-
$this->set("title_for_layout","Page Title Value");
Rest of the post is deprecated
To set a page title in CakePHP in your controller write
-
$this->set('title', 'My Page Title');
or the less preferred and probably soon to be deprecated
-
$this->pageTitle = 'My Page Title'
However if you are using the pages controller to render a few static pages and want custom title, in your view (static page) use
-
$this->pageTitle = 'My page title';
Hope that helped
I'm not quite sure that the second one will be deprecated. At least not in full.
I often use the format at the top of my controller:
var $pageTitle = 'My Page Title';
This is quite useful for setting a global page title. It's by far the easiest way to do it globally that I'm aware of
Thanks. I don't know why they make this change.
yes that helped!
Splendid! Thanks a lot for responding to your visitors' habits.
Nice quick answer! I like how you molded the page to what people were searching for. I could learn something from this.
Hey the third code block is the same as the second one.
Yes, of course it has to be the same - please read it in context of what is written
This has now been changed to $this->set("title_for_layout", "My page title");
Thanks for this wonderful and very helpful information.