Assigning Variables - e.g. $this->fetch('title') - CakePHP4

Assigning variables (e.g. in a controller) so they are available in your views & layouts

 

Assign a title from a view or controller

$this->assign('title', 'Dashboard'); 

 

Fetch the variable from within a view or layout

echo $this->fetch('title');

Share this Post