If you want to set the title of a page, you have three different ways to accomplish that.

The first two approaches use the magic variable “title_for_layout” to set the title in the layout:

<title>
    <?php echo $title_for_layout;?>
</title>

You can set the value for this magic variable either in the controller:

public $pageTitle = 'The title';  // same title for all actions

or

public function test() {
    $this->pageTitle = 'The title';
    ...
}

or in the view file:

<?php $this->pageTitle = 'The title';?>
...

The third, and last, approach uses a custom variable in the layout instead of the magic variable:

<title>
    <?php echo $pageTitle;?>
</title>

Its value is then set in the controller, in the same way you put other data to the view:

public function test() {
    ...
    $this->set('pageTitle', 'The title');
}

Now, which approach should you use? I think it is a matter of preference. From a conceptual point of view I prefer the third approach as it doesn’t use any magic, but in practice I usually use the second (maybe this will change after this article *g*). The first approach I consider as a bad practice, because a controller doesn’t represent a page and hence it shouldn’t have a pageTitle property.