Back to Top

add custom module layout in magento

Updated 29 February 2024

step1-Create block file (.phtml) in your template folder.
step 2-Then goes to layout folder and open yourmodulename.xml file (yourmodulename.xml is as you module) if this file not exist in layout folder then check in config.xml file of your module and find following code

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<adminhtml>
<layout>
<updates>
<quicklogin>
<file>quicklogin.xml</file>
</quicklogin>
</updates>
</layout>
</adminhtml>
<adminhtml> <layout> <updates> <quicklogin> <file>quicklogin.xml</file> </quicklogin> </updates> </layout> </adminhtml>
Explain Code
Powered By
<adminhtml>
   <layout>
    <updates>
      <quicklogin>
        <file>quicklogin.xml</file>
      </quicklogin>
    </updates>
  </layout>
</adminhtml>

in the string use is the name of your module layout.xml here module layout file is “quicklogin.xml”
the open it and add the following code

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<?xml version="1.0"?>
<layout version="0.1.0">
<default>
<!-- here add block which you want to display on every page of your website!-->
<block type="core/template" name="quicklogin" output="toHtml" template="quicklogin/quicklogin.phtml" />
</default>
<!--after default tag we add blocks which we want to display on particular page !-->
<catalog_product_view><!--this identify the product page!-->
<reference name="right"><!--reference define the layout!-->
<block type="core/template" name="wk-block" output="toHtml" before="cart_sidebar" template="catalog/product/wk_block.phtml" />
</reference>
</catalog_product_view>
</layout>
<?xml version="1.0"?> <layout version="0.1.0"> <default> <!-- here add block which you want to display on every page of your website!--> <block type="core/template" name="quicklogin" output="toHtml" template="quicklogin/quicklogin.phtml" /> </default> <!--after default tag we add blocks which we want to display on particular page !--> <catalog_product_view><!--this identify the product page!--> <reference name="right"><!--reference define the layout!--> <block type="core/template" name="wk-block" output="toHtml" before="cart_sidebar" template="catalog/product/wk_block.phtml" /> </reference> </catalog_product_view> </layout>
Explain Code
Powered By
<?xml version="1.0"?>
  <layout version="0.1.0">
   <default>
     <!-- here add block which you want to display on every page of your website!-->
     <block type="core/template" name="quicklogin" output="toHtml" template="quicklogin/quicklogin.phtml" />
   </default>
   <!--after default tag we add blocks which we want to display on particular page !-->
   <catalog_product_view><!--this identify the product page!-->
     <reference name="right"><!--reference define the layout!-->
        <block type="core/template"  name="wk-block" output="toHtml" before="cart_sidebar" template="catalog/product/wk_block.phtml" />
    </reference>
  </catalog_product_view>
</layout>

///
explanation of block tag attributes
type: define the type of data which display in this block it is Basically the name of class which return it,
name:identify you block,
output:output formate,
before and after: where your block stay in that layout,
template:path of your block file(.phtml) which you create for content of your block
///

Searching for an experienced
Magento Company ?
Find out More
. . .

Leave a Comment

Your email address will not be published. Required fields are marked*


Be the first to comment.

Back to Top

Message Sent!

If you have more details or questions, you can reply to the received confirmation email.

Back to Home