Posts tagged ‘Blocks’
Blocks
Blocks
Blocks are the brains behindMagento’s templating scheme. Blocks forma nested set of objects that coordinate the models with the template files. Each block controls one template file: a simple HTML and PHPmixed file with a .phtml extension. What this means is that for any page request on Magento, you are dealing with an equal, but large, number of Block objects and .phtml template files. All blocks extend the base class Mage_Core_Block_Template, which, in turn, extends Mage_Core_Block_Abstract. The chief method of a block is its toHtml() method.
This method translates the block’s template file into HTML using the renderView() method. Magento’s template system is just plain PHP. They don’t re-implement any other templating system, so the renderView() method simply does an include() on the requested .phtml template file. If, in fact, you wanted to add a different templating mechanism into Magento, the Mage_Core_Block_Template class’s renderView method is where you would trigger your chosen template system’s rendering functions.
Recent Comments