Friday, February 18, 2022

[FIXED] using title in view (template) in CakePHP 3

Issue

I want to print title in my view (Template) in CakePHP3.

$this->fetch('title') is working fine in element and default.ctp but when using this in view it is printing nothing.

How could I print title in view using $this->fetch('title')?


Solution

In your view file you should assign some value to the title variable

$this->assign('title', 'Example title text');

Than in your template you should have

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


Answered By - rrd

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.