I need to add a block right after the breadcrumbs in one of my pages, my-page

I tried creating a block called my-block in the admin, and adding <?php echo $this->getChildHtml('my-block') ?> in frontend/theme/default/template/page/2columns-left.phtml and it doesn't show the contents of the block my-block.

I also added

    <reference name="root">
        <block type="core/template" name="my-block" as="my-block" before="content" after="breadcrumbs" template="page/html/my-block.phtml"/>

In the local.xml file, but I'm not sure if it was really necessary.

Am I missing something?


  • Where did you add that layout xml? – Erfan Mar 24 '15 at 1:22

if my-page is a cms page and you want to show your custom block only in this cms page, then this is what you need to include a custom block just below the breadcrumb block.

1. Define your custom block

File : app\design\frontend\[package]\[theme]\layout\local.xml

<cms_page_view> <!-- layout update handle -->
    <reference name="root"> <!-- parent block of our custom block -->
        <block type="core/template" name="my.custom.top.block" as="my_custom_top_block" template="custom/template.phtml" /> <!-- definition of custom block -->

This code snippet defines our block and include it in root block in the case of a cms page rendition. This means this block will be available when a cms page is rendered in frontend. You need to include the block inside root block because it is the block which holds all structural blocks and breadcrumb block is a structural block. Obviously your block is also a structural block.

2. Specify Where should Custom Block Appear

This is the next important step. Defining a block will not render your block automatically. You need to specify where should it appear. For that you need to open the root template and add the below code there

File : app\design\frontend\[package]\[theme]\template/page/[root-template].phtml

<div class="main">
    <?php echo $this->getChildHtml('breadcrumbs') ?>
    <?php echo $this->getChildHtml('my_custom_top_block') ?>
    <div class="col-main">
        <?php echo $this->getChildHtml('global_messages') ?>
        <?php echo $this->getChildHtml('content') ?>

Here [root-template].phtml would be the active root template in your theme. Eg : 1column.phtml, 2columns-left.phtml etc. It would be good if you add the line <?php echo $this->getChildHtml('my_custom_top_block') ?> just below breadcrumb call in every root templates as I shown above (root templates are phtml files which are avaialable in template/page folder).

3. Define your custom block template

This is the last step. Go ahead and create a custom block template which we have specified in our layout udpate.

File : app\design\frontend\[package]\[theme]\template/custom/template.phtml

<div> UREKKAAAA </div>

Now clear the cache and load the page again. You will see UREKKAAAA just below breadcrumb.

  • @Gazta : sorry I didnt get you. – Rajeev K Tomy Mar 24 '15 at 2:14

Widget, or Layout update

for Layout can try like this code

<reference name="top.container">
    <block type="core/template"

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.