Welcome to Magento blog! Normally, if someone wants to show a block, the first thing he may think about is to insert some codes to template file page/1column.phtml. It is really unstable when you change your theme like this. However, Magento provides a block concept called Structure Block which allows you to absolutely avoid this problem.

You may concern:
How to add a block to product page without modifying template

What is structure block?

It’s a block which contains others and displays all of their children blocks.

Where are structure blocks located?

You are able to find them in the layout files of Magento. They are having a type of “core/text_list”. In the page.xml file, you can see structure blocks such as: after_body_start, top.menu, left, content, right, before_body_end.

To insert your block into a structure block, you may take the following steps:

  • Open layout file of your module
  • Insert this code  to layout file
<default>
<!— insert to above of header -->
<reference name="after_body_start">
<block type="Module_Name/Block_Name" template="Module_Name/Template_File_Name.phtml"/>
</reference>

<!— insert to below of top menu -->
<reference name="top.menu">
<block type="Module_Name/Block_Name" template="Module_Name/Template_File_Name.phtml"/>
</reference>
</default>

Please note that you have to replace Module_Name, Block_Name and Template_File_Name with the specific values. Now take a look at the screenshot below to see how your block will be shown:

If you have any questions, matters or difficulties when manipulating, let me know, OK?

Over and out…bye bye…Hope to see you again in Magento blog!

Related Tutorials:

Author

Alex is the CTO & Co-founder of Magestore which has been providing retail solutions for Magento merchants since 2009. He started as a Magento developer just one year after the release of the first version of Magento. With over 10 years experience of working with Magento and clients all over the world, he gained great knowledge on e-commerce development, order management systems, inventory control & retail POS.

Write A Comment