Magento Cheat Sheet – Frontend local.xml snippets

Here are some other set of help with magento frontend coding with local.xml.

Hope this find help for someone. Trying to make things easier for everyone. There are much more info available on our Q&A section of website www.phponlinesupport.com. Please make use of search to find the right info from the list.

Frontend local.xml snippets

 

Change page template

<reference name="root">
    <action method="setTemplate"><template>page/template_file.phtml</template></action>
</reference>

 

Add/remove CSS/JS

<reference name="head">
    <action method="addItem"><type>skin_css</type><name>css/file.css</name><params/></action>
    <action method="addItem"><type>skin_js</type><name>js/file.js</name><params/></action>
    <action method="removeItem"><type>skin_css</type><name>css/file.css</name><params/></action>
    <action method="removeItem"><type>skin_js</type><name>js/file.js</name><params/></action>
</reference>

 

Move block position

<reference name="old_parent">
    <action method="unsetChild"><name>block_name</name></action>
</reference>
<reference name="new_parent">
    <action method="insert"><block>block_name</block></action>
</reference>

 

Remove block

<remove name="block_name" />

 

Add crumb to breadcrumbs

<reference name="breadcrumbs">
    <action method="addCrumb">
        <crumbName>Link Text</crumbName>
        <crumbInfo>
            <label>Link Text</label>
            <title>Link Text</title>
            <link>/link-url</link>
        </crumbInfo>
    </action>
</reference>

 

Insert CMS block – usage: $this->getChildHtml(‘relevant_name’)

<block type="cms/block" name="relevant_name">
    <action method="setBlockId"><block_id>static_block_identifier</block_id></action>
</block>

 

Insert template file – usage: $this->getChildHtml(‘relevant_name’)

<block type="core/template" name="relevant_name" template="page/html/template_file.phtml" />

 

Add address fields to customer signup form

<customer_account_create>
    <reference name="customer_form_register">
        <action method="setShowAddressFields"><param>true</param></action>
    </reference>
</customer_account_create>