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
Post a Comment