I'm trying to insert a block that shows up at a specific point in my page. I created a new layout file, which looks like this:


<layout version="0.1.0">
    <reference name="content">
        <block type="core/template" after="-" name="my.block" template="my_dir/myblock.phtml" />

This successfully displays the html content in myblock.phtml, at the top of my content block. How can I make this block render after another block, such as this one:


<block type="catalog/product_view" name="product.info.addtocart" as="addtocart" template="catalog/product/view/addtocart.phtml"/>

Intuitively, I thought this would work, but didn't:

<layout version="0.1.0">
    <reference name="product.info">
        <!--in config file / Istockphp\Customerpage\Block\Customer.php-->
        <block type="core/template" after="product.info.addtocart" name="product.reward" template="socilogica/product_reward.phtml" />

Appreciate any help!

1 Answer 1


Auto render child blocks for Mage_Core_Block_Text_List

As per as magento,a block is automatically rendered when it parent block class is Mage_Core_Block_Text_List.

On first xml code ,you have put <block type="core/template" after="-" name="my.block" template="my_dir/myblock.phtml" /> as child block of block content.

see at page.xml

<block type="core/text_list" name="content" as="content" translate="label">
                <label>Main Content Area</label>

As content block type is core/text_list that means it block class Mage_Core_Block_Text_List.So my.block automatically rendered.

Render child block by $this->getChildHtml()

But in second xml code,block name is product.info,which is block type is catalog/product_view which block class is not core/text_list.This block class Mage_Catalog_Block_View.

<block type="catalog/product_view" name="product.info" template="catalog/product/view.phtml">

So,if you want to rendered it child block automatically then it not possible without call all child Blocks by using <?php echo $this->getChildHtml()?>

Or ,specific child block using <?php echo $this->getChildHtml(cHilblockname)?> .

As on view.phtml it all child blocks are not by rendere <?php echo $this->getChildHtml()?> and each child block render individual call

<?php echo $this->getChildHtml('childblockname')?> then you need add

<?php $this->getChildHtml('product.reward');> at view.phtml
  • 1
    thank you Amit. How would I be able to render my block after the product.info.addtocart block? When I render my block with the code above, my output displays at the bottom of the page, after the footer. Commented Apr 8, 2015 at 19:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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