php - $this->set('title', 'Title Name'); not working in CakePHP 3.x -


basically in default.ctp have title:

<title>   <?= $this->fetch('title') ?> </title> 

and inside of controller have line:

$this->set('title', 'test-title'); 

but nothing, still displays controllers name(jobs, controllers full name os jobscontroller.ctp)

but if put inside of view file:

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

it changes title. wrong $this->set('title', $title) ?

you can set() variable in controller:

// view or controller $this->set('title', 'test-title'); 

then use standard variable in layout or view:

<!-- layout or view --> <title>     <?php echo $title; ?> </title> 

details here: http://book.cakephp.org/3.0/en/views.html#setting-view-variables

using assign() different, why works fetch(). assign() used view blocks: http://book.cakephp.org/3.0/en/views.html#using-view-blocks


Comments

Popular posts from this blog

android - MPAndroidChart - How to add Annotations or images to the chart -

javascript - Add class to another page attribute using URL id - Jquery -

firefox - Where is 'webgl.osmesalib' parameter? -