The use of the params
property to allow communication between view and layout, is advisable for simple cases, but there are some more complex cases where we must share the block of HTML.
For example, think about the advertising box in layout (usually left or right column of the template), that could change according to the view that is being displayed.
In this case, we need to pass the entire block of HTML code from view to layout.
For this purpose, this framework provides Block statements, where we can define entire blocks of data to send from view to layout.
Using Blocks means to define the Block
statement in view and display it in another view, usually layout.
We define the Block
statement in view as follows:
<?php $this->beginBlock('block1'); ?> ...content of block1... $this->endBlock(); ?>
Here, beginBlock
and endBlock
define the beginning and the end of the block1
named statement. This content is saved into the blocks
property of the view component...