The working mechanism of Magento Controllers and Blocks are way too different. So inorder to pass data between Magento Controller and Block, it is necessary to understand how they work together. Briefly, the Controller’s job is to carry out the task of Models and inform the system about the layout’s rendering time. While Blocks need to display HTML pages depending on the state of the system models.
There are a number of ways to pass data between Magento Controller and Block. This blog post covers one such method. Follow the steps given below to pass data between Magento Controller and Block easily.
In case of Magento content management system, the view is layout and blocks only. So controllers are not responsible for setting variables for the view in the MVC approach. Controllers only set the values on models while Blocks read from those models.
So to completely relying on a mechanism to pass data between Magento Controller and Block directly is not recommended. It is because of the tight coupling involving the two.
The second time it is instantiated to read the values back. Magento instantiates the object as a singleton. So each time the object is instantiated, the same object is returned. This is the best method to pass data between Magento Controller and Block.