Create your own Backend theme

When developing Magento Backend functionalities, sometimes you need to add own layout files or templates. In these cases it is a good idea to create a new Backend theme under adminhtml and to modify the Magento configuration to lookup layout files and templates in this new theme before searching in the default one. Therefore you have to create […]

Trigger layout handle in another layout handle

In most cases you don’t want to write the same layout declaration twice. With the following snippet you can trigger a once written layout handle in other layout handles. So you can reuse the declaration. <modul_controller_action> <update handle=”modul_controller_action”/><!–layout handle to trigger–> </modul_controller_action>

Add JavaScript or CSS in Block class

 To add JavaScript or CSS files to the head section of the resulting HTML page, you can add something like this to the _prepareLayout function of a Block class: $headBlock = $this->getLayout()->getBlock(‘head’); $headBlock->addJs(‘somefolder/ask-sheldon.js’); $headBlock->addCss(‘somefolder/ask-sheldon.css’); As you can see, we can use the layout model to get the head block an use its functions to add files. This […]

Add static block to cms page

First, you can use the XML-Layout-Update of the respective page (or other layout updates in every layout xml file ): <reference name=”content oder right oder left”> <block type=”cms/block” name=”blockname”> <action method=”setBlockId”><id>BLOCK-ID</id></action> </block> </reference> Or you can use the following placeholder: {{block type=”cms/block” block_id=”BLOCK-ID” template=”cms/content.phtml”}}

Add link to header navigation

The following code inserts a link for extended search into the headers top link navigation <reference name=”top.links”> <action method=”addLink”> <label>Advanced Search</label> <url>catalogsearch/advanced</url> <title>Advanced Search</title> <prepare>false</prepare> <urlParams></urlParams> <position>6</position> </action> </reference> It is really important, that all sub elements of  the action tag are in the exact this order as the corresponding parameters of the underlaying method Mage_Page_Block_Template_Links:: […]