-4

Please explain all the attributes of Magento block tag

<block type="catalog/product_featured" name="product_featured" 
     as="product_featured" 
     template="catalog/product/featured.phtml"></block>
<block type="catalog/product_featured" name="product_featured"              template="catalog/product/featured.phtml">
<action method="setLimit"><limit>2</limit></action>
 </block>

also why do we need two times the block tag

Ankit Agarwal
  • 166
  • 1
  • 1
  • 11
  • There is documentation and tutorials out there that will teach you the basics of Magento blocks. This isn't the appropriate place to be asking for explanations of the basic principles of Magento (unless you've exhausted the resources yourself). – Axel Apr 22 '13 at 17:18

1 Answers1

0

type = PHP file the template will look for the methods.. Here it is Mage_Catalog_Block_Product_Featured.php

name = Name of the block. It should be unique in the page.

as = Alias. Smaller form of name. It should be unique in it's parent block.

template = The template file (View) this block is attached to. You can call methods from block type inside this by using $this.. e.g. $this->getName()

name vs. as example:

<reference name="left">
    <block type="block/type1" name="first_block" template="template1.phtml">
       <block type="abc/abc" name="abc" as="common" template="abc.phtml"/> 
    </block>
    <block type="block/type2" name="second_block" template="template2.phtml">
       <block type="xyz/xyz" name="xyz" as="common" template="xyz.phtml"/>            
    </block>
</reference>

So, you can now call block name abc from first_block AND xyz from second_block as $this->getChildHtml('common');, but see both the blocks called will be different as per their calling parent.

Kalpesh
  • 5,635
  • 2
  • 23
  • 39