3. Layouts
Don't repeat yourself¶
Each module need a file inside the views to be the default HTML for all actions, we mean, all .phtml
scripts will be rendered inside this file. It's called layout
because it contain all HTML parts which are repeated in all pages from your system. Is not necessary to do any include
or require
to include this file, SuitUp do it for you automatically.
Where you include on your layout HTML the variable
<?php echo $content; ?>
is where will be rendered (printed) the content from view.
The layout¶
File: ModuleDefault/views/layout.phtml
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
|
If you enabled the 'SQL monitoring', point in your layout where you want this HTML injection to be printed, generally at the end of the file, but before </body>
tag.
Layout messages¶
Inside any action from any controller you can call the method $this->addMsg("mensagem", MsgType::SUCCESS, true);
to messages that will be displayed in the layout after a redirect or $this->addMsg("mensagem", MsgType::SUCCESS);
to messages that will be direct displayed in the layout.
For this work well add these lines below anywhere in your layout.phtml
file
1 2 3 4 5 6 7 8 9 |
|
See more about this [[here|2.1-MvcAbstractController-(en)#addMsg]].