Search code examples
magento

Understanding Magento Block and Block Type


I just want to understand the meaning of

 <block type="page/html" name="root" output="toHtml" template="example/view.phtml">

I got many references from Google and understood many things about it but I am still unable to understand the formation of type="page/html" how to form a type for my custom module.

Please explain

type="A/B"

Let me know where this A and B come from?


Solution

  • The A is a module's alias. In this case page is short for Mage_Page_Block (it is defined in app/code/core/Mage/Page/etc/config.xml if you want to see).

    The B is the class name relative to the alias, initial letters of each word are capitalised. In this case html becomes Html and is appended to the resolved alias, so it is Mage_Page_Block_Html. This is probably found in the file app/code/core/Mage/Page/Block/Html.php because class names translate directly to locations in Magento.

    Were you using a model alias instead of a block alias then page would be Mage_Page_Model instead. The same thing happens for resource models and helpers too. Your own module will need to define these in it's config if it is to have blocks, models and helpers.