Inside the /default.ctp layouts, you will see something like this on line 39:
<div class="header-title"> <span><?= $this->fetch('title') ?></span> </div>
fetch assumes this is a view block. I could not find this viewer anywhere.
Currently, it just displays the uppercase plural form of the controller. The point is to say if you are in /users/add , fetch('title'); gives you 'Users'
I want to change it. So I tried the following:
$this->set('title', 'Login');
in the controller action /users/login .
Does not work.
I also tried
$this->assign('title', 'Login');
in the controller action /users/login .
I get this error message:
Call to undefined method App\Controller\UsersController::assign()
I read the docs here too
I get
Assigning the contents of blocks is often useful when you want to convert a view variable into a block. For example, you can use the block for the page title and sometimes assign the title as a view variable in the controller :
Emphasis is mine.
This suggests that you can use the internal assign controller. I think I proved this to be wrong.
There may be a typo in the documents. Please advise how I can set the title
source share