@@ -96,6 +96,9 @@ Avoid extending this template class, because with inheriting the template block
9696If you need custom presentation logic in your blocks, use this class as block, and declare
9797custom view models in block arguments in layout handle file.
9898
99+ View model parameter can have any name.
100+ Also, one block can have multiple view models injected via layout.
101+
99102Example:
100103
101104``` xml
@@ -109,7 +112,7 @@ Example:
109112In template, access your model instead of the block:
110113
111114``` php
112- $viewModel = $block->getViewModel( );
115+ $viewModel = $block->getData('viewModel' );
113116```
114117
115118[ ViewModels in Magento 2] ( https://www.yireo.com/blog/1856-viewmodels-in-magento-2 )
@@ -134,9 +137,9 @@ At this stage all blocks in layout are generated, but _prepareLayout is only run
134137
135138`_beforeToHtml`:
136139- can't change page title?
137- - some block are rendered, can't change them
140+ - some blocks are rendered, can't change them
138141- assign additional template values
139- - delay computation to latest point until render. if block is not rendered we save computation
142+ - delay computation to the latest point until render. If block is not rendered we save computation
140143
141144`_toHtml`:
142145- block without template, put custom rendering here, e.g. calling external API
0 commit comments