ANATOMY OF A MAGENTO LAYOUT FILE
<Handle>
Handle is an identifier by which the application determines what to do with the updates nested by it.
If the name of the handle is <default>, then the application knows that its nested updates must be loaded on almost all the pages of the store prior to loading page-specific layout (”almost all” because some exceptional pages like the product image popup do not load the layout in the <default> handle).
If Magento finds handles other than <default>, it will assign the updates nested inside the handle to the according page specified by the handle.
For instance, <catalog_product_view> contains the layout updates for the Product View page, while <catalog_product_compare_index> contains those for the Compare Product page.
Handles are set-in-stone identifiers that a designer, with no extensive understanding of Magento programming, should never need to modify.
-----------------------------------------------------------
<BLOCK>
Magento determines the behavior and visual representation of each building block of a page via the <block> tag. We have already mentioned the two types of blocks Magento employs
- structural blocks and content blocks.
A structural block usually contains the attribute ”as,” through which the application is able to communicate with the designated area (using the getChildHtml method) in a template
You will notice many occurrences of this ”as” attribute in the default layout, because by nature the default layout is one that builds the groundwork upon which the page-specific layouts can begin adding onto. For instance, in the default layout, there are structural blocks such as ”left,” ”right,” ”content” and ”footer” being introduced.
basisThe available attributes for <block> are:
• type – This is the identifier of the module class that defines the functionality of the block. This attribute must not be modified.
• name – This is the name by which other blocks can make reference to the block in which this attribute is assigned (see diagram 3).
• before (and) after – These are two ways to position a content block within a structural block. before=“-” and after=“-” are commands used to position the block accordingly at the very top or very bottom of a structural block.
• template - This attribute determines the template that will represent the functionality of the block in which this attribute is assigned. For instance, if this attributes is assigned ‘catalog/category/view.phtml’, the application will load the ‘app/design/frontend/template/catalog/category/view.phtml template file.
• action – <action> is used to control store-front functionalities such as loading or unloading of a JavaScript. A full list of action methods will soon become available, but in the mean time the best way to learn about the different action methods is by playing around with them in the currently available layout updates.
• as – This is the name by which a template calls the block in which this attribute is assigned. When you see the getChildHtml(‘block_name’) PHP method called from a template, it is referring to the block whose attribute ”as” is assigned the name ‘block_name’. (i.e. The method <?=$this->getChildHtml(‘header’)?> in the a skeleton template correlates to <block as=“header”> ).
------------------------------------------------------------------------
<REFERENCE>
<reference> is used to make reference to another block. By making a reference to another block, the updates inside <reference> will apply to the <block> to which it correla
To make the reference, you must target the reference to a block by using the ”name” attribute. This attribute targets the <block> tag’s ”name” attribute. Therefore, if you were to make a reference by <reference name=“right”>, you are targeting the block named <block name=“right“>
To make the reference, you must target the reference to a block by using the ”name” attribute. This attribute targets the <block> tag’s ”name” attribute. Therefore, if you were to make a reference by <reference name=“right”>, you are targeting the block named <block name=“right“>.
-----------------------------------------------------------------------
RULES OF XML
The only set rule you need to remember with regard to XML is that when a tag opens, it must either be followed by a closing tag(<xml_tag></xml_tag>) or self-close(<xml_tag/>) exactly as required by xHTML file tags.
-----------------------------------------------------------------------
HOW TO FIND WHICH LAYOUT FILE TO MODIFY
To access the layout files, go to app/design/frontend/design_package/theme_variation/layout/. Just like the templates, layouts are saved on a per-module basis therefore you can easily locate the layout file to modify with the help of the Template Hints.
To enable Template Hints, go to System -> Configuration -> Advanced -> Developer. At this point you will need to make sure you have your website selected in the Current Configuration Scope dropdown instead of Default Config. Once your website is selected in the dropdown, click Debug. Here, you can change Template Path Hints to Yes. If you want even further information, you can also change Add Block Names to Hint to Yes.
------------------------------------------------------------------------
Remove some unwanted stuffs
Create a file named local.xml. Inside of local.xml, create a <default> block that will contain and consolidate your global changes:
<?xml version="1.0" ?>
<layout>
<default> <!-- Your block overrides will go here -->
</default>
</layout>
Depending on what you want to turn off, local.xml might contain some of the following lines.
<default>
<remove name="left.permanent.callout" /> <!--the dog-->
<remove name="right.permanent.callout" /> <!--back to school-->
<remove name="catalog.compare.sidebar" /> <!--product compare-->
<remove name="paypal.partner.right.logo" /> <!--paypal logo-->
<remove name="cart_sidebar" /> <!--cart sidebar-->
<remove name="left.reports.product.viewed" /> <!--recently viewed prod-->
<remove name="right.reports.product.viewed" /> <!--recently viewed prod-->
<remove name="right.reports.product.compared" /> <!--recently compared prod-->
</default>
<Handle>
Handle is an identifier by which the application determines what to do with the updates nested by it.
If the name of the handle is <default>, then the application knows that its nested updates must be loaded on almost all the pages of the store prior to loading page-specific layout (”almost all” because some exceptional pages like the product image popup do not load the layout in the <default> handle).
If Magento finds handles other than <default>, it will assign the updates nested inside the handle to the according page specified by the handle.
For instance, <catalog_product_view> contains the layout updates for the Product View page, while <catalog_product_compare_index> contains those for the Compare Product page.
Handles are set-in-stone identifiers that a designer, with no extensive understanding of Magento programming, should never need to modify.
-----------------------------------------------------------
<BLOCK>
Magento determines the behavior and visual representation of each building block of a page via the <block> tag. We have already mentioned the two types of blocks Magento employs
- structural blocks and content blocks.
A structural block usually contains the attribute ”as,” through which the application is able to communicate with the designated area (using the getChildHtml method) in a template
You will notice many occurrences of this ”as” attribute in the default layout, because by nature the default layout is one that builds the groundwork upon which the page-specific layouts can begin adding onto. For instance, in the default layout, there are structural blocks such as ”left,” ”right,” ”content” and ”footer” being introduced.
basisThe available attributes for <block> are:
• type – This is the identifier of the module class that defines the functionality of the block. This attribute must not be modified.
• name – This is the name by which other blocks can make reference to the block in which this attribute is assigned (see diagram 3).
• before (and) after – These are two ways to position a content block within a structural block. before=“-” and after=“-” are commands used to position the block accordingly at the very top or very bottom of a structural block.
• template - This attribute determines the template that will represent the functionality of the block in which this attribute is assigned. For instance, if this attributes is assigned ‘catalog/category/view.phtml’, the application will load the ‘app/design/frontend/template/catalog/category/view.phtml template file.
• action – <action> is used to control store-front functionalities such as loading or unloading of a JavaScript. A full list of action methods will soon become available, but in the mean time the best way to learn about the different action methods is by playing around with them in the currently available layout updates.
• as – This is the name by which a template calls the block in which this attribute is assigned. When you see the getChildHtml(‘block_name’) PHP method called from a template, it is referring to the block whose attribute ”as” is assigned the name ‘block_name’. (i.e. The method <?=$this->getChildHtml(‘header’)?> in the a skeleton template correlates to <block as=“header”> ).
------------------------------------------------------------------------
<REFERENCE>
<reference> is used to make reference to another block. By making a reference to another block, the updates inside <reference> will apply to the <block> to which it correla
To make the reference, you must target the reference to a block by using the ”name” attribute. This attribute targets the <block> tag’s ”name” attribute. Therefore, if you were to make a reference by <reference name=“right”>, you are targeting the block named <block name=“right“>
To make the reference, you must target the reference to a block by using the ”name” attribute. This attribute targets the <block> tag’s ”name” attribute. Therefore, if you were to make a reference by <reference name=“right”>, you are targeting the block named <block name=“right“>.
-----------------------------------------------------------------------
RULES OF XML
The only set rule you need to remember with regard to XML is that when a tag opens, it must either be followed by a closing tag(<xml_tag></xml_tag>) or self-close(<xml_tag/>) exactly as required by xHTML file tags.
-----------------------------------------------------------------------
HOW TO FIND WHICH LAYOUT FILE TO MODIFY
To access the layout files, go to app/design/frontend/design_package/theme_variation/layout/. Just like the templates, layouts are saved on a per-module basis therefore you can easily locate the layout file to modify with the help of the Template Hints.
To enable Template Hints, go to System -> Configuration -> Advanced -> Developer. At this point you will need to make sure you have your website selected in the Current Configuration Scope dropdown instead of Default Config. Once your website is selected in the dropdown, click Debug. Here, you can change Template Path Hints to Yes. If you want even further information, you can also change Add Block Names to Hint to Yes.
------------------------------------------------------------------------
Remove some unwanted stuffs
Create a file named local.xml. Inside of local.xml, create a <default> block that will contain and consolidate your global changes:
<?xml version="1.0" ?>
<layout>
<default> <!-- Your block overrides will go here -->
</default>
</layout>
Depending on what you want to turn off, local.xml might contain some of the following lines.
<default>
<remove name="left.permanent.callout" /> <!--the dog-->
<remove name="right.permanent.callout" /> <!--back to school-->
<remove name="catalog.compare.sidebar" /> <!--product compare-->
<remove name="paypal.partner.right.logo" /> <!--paypal logo-->
<remove name="cart_sidebar" /> <!--cart sidebar-->
<remove name="left.reports.product.viewed" /> <!--recently viewed prod-->
<remove name="right.reports.product.viewed" /> <!--recently viewed prod-->
<remove name="right.reports.product.compared" /> <!--recently compared prod-->
</default>
No comments:
Post a Comment