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.

September 10, 2009 at 3:14 am Leave a comment


Recent Posts

Categories

Archives

Top Posts

    Top Rated

    Blog Stats

    • 6,373 hits

     

    June 2012
    M T W T F S S
    « Sep    
     123
    45678910
    11121314151617
    18192021222324
    252627282930  

    Follow

    Get every new post delivered to your Inbox.