A general block that is using in layout file will look like this.
<block type="custom/whatever" name="custom.whatever.block" as='useme' template="whatever.phtml" />
I will go through each attribute in short now
1. type :- This is the most important part of a block. Without specifying a type, a block will not become a real block !. Type points to the actual behaviour of a particular block. This means blocks with different type behaves differently and they dont have any relation between themselves except they may be inherits from same parent classes. When we specify a type of a block, it is required that, it is defined backside of the module. For an example type="core/template"
needs Mage_Core_Block_Template
class to be defined. Otherwise Magento will not identify your block.
2. name :- This attribute is clear by its "name" itself. We are giving a name for this block in order to identify this block uniquely. You need to always use a unique name for your block. The use of name of a block is very much important to understand. Suppose you need to use above mentioned block to be used further inside any other layout xml files, then in that case, we will "refer" the above block by its name. ie <reference name="custom.whatever.block" />
. Note that name of the block is actually using everywhere for future reference.
3. as :- This is the alias name of a block. as
value is mainly using in phtml file in order to call a block. Please note, if you use name
field to refer a block inside a phtml file, it simply wont work. I think as
is perfect to denotation for alias name. You can read it as use this block as "useme" in a phtml file
(as per above example).
A block is invoked in a phtml like this
<?php echo $this->getChildHtml('useme'); //useme is `as` value.
Now magento will get the block and render its content in that place.
4. template :- This is used to set a template file to a block. template file will hold design part of a block. A template file is actually an instance of type
of the block to which that block is connected. In the above case whatever.phtml
will be an instance of Namespace_Modulename_Block_Whatever
where Namespace_Modulename
is hypothetical custom module that holds this block.