How to alter view blocks content from controller in CakePHP 3? -
Layout / default. Inside TTP you will see on line 39 such as this:
& Lt; Div class = "header-title" & gt; & Lt; Span & gt; & Lt ;? = $ This- & gt; Lana ('title')? & Gt; & Lt; / Span & gt; & Lt; / Div & gt;
get
suggests that this is a visual block, I do not find this visual block anywhere.
Currently it only displays the capitalized plural form of the controller. If you are in / user / add
, then fetch ('title');
gives you 'users'
I want to change it. So I tried the following:
$ this-> Set ('title', 'login');
Gt; Assign ('Title', 'Login'); / user / login
controller action in
.
I get this error message:
Call the unchanged method App \ Controller \ UsersController :: assign ()
I read the document
I found
Assigning a block's contents is often useful when you want to convert a visible variable to a block. For example, you might want to use a block for the page title, and sometimes in the form of a visual variable in Controller :
You can specify. / P>
It shows that you can use the assign
inside the controller, I think I have proven that this is wrong.
Maybe there is a typo in the documents, please advise how I can set the title
Thanks for the Dakota of IRC Channel #cakephp.
inside UsersController.php
:
$ this-> Set ('title', 'login'); Get the $ the-> inside src / template / layouts / default.ctp
('title');
Write:
if (isset ($ title)) {$ this-> Assign ('title', $ title); }
How will the question be raised by how did the CapePP 3 define the default value?
The answer is found in the
link rot in the case of adding the image
Where you can see the default in the visual path
Comments
Post a Comment