In this case I suppose that I can call this block in a phtml as getBlockHtml('my.name') right !

To call it as getChilHtml('my.name') what do I have to do in a xml ?

    <reference name="content">
        <block type="core/template" name="my.name" template="page/custom/my-template.phtml" />

1 Answer 1


getChildHtml can be used to retrieve a child block HTML.


    <reference name="content">
        <block type="core/template" name="my.name" template="page/custom/my-template.phtml">
            <block type="core/template" name="my.child" template="my/template.phtml" />

In that case in your page/custom/my-template.phtml template (your my.name block) you can call echo $this->getChildHtml('my.child'); to get the HTML of your child my.child

getBlockHtml can be used to retrieve a block HTML, understand any block.

An easy to understand example from the core is the form key block declared like this:

<layout version="0.1.0">
        <block name="formkey" type="core/template" template="core/formkey.phtml" />

As you can see it's just a block assigned to every page.

In any template you can call <?php echo $this->getBlockHtml('formkey')?> to display that block

Clarification regarding your question

In your case, you've assigned the block to the content structural block declared in the page.xml layout file:

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

As this is a structural block (of type core/text_list) you don't need to do anything to get your custom block rendered because structural blocks render all their child automatically

  • Thank Raphael for your reply, however i want to know something, in the xml declaration we can declare all type block as "core/template" in all cases because all blocks types inherits core/tempate right ? when i can check this in the code
    – PЯINCƎ
    Jan 26, 2017 at 10:22
  • 1
    @Prince most of the time it's core/template but you can also declare structural blocks (core/text_list) or simple text block (core/text) Jan 26, 2017 at 10:24
  • Thanks, are you from france ?
    – PЯINCƎ
    Jan 26, 2017 at 10:25
  • @Prince yes I am Jan 26, 2017 at 10:26
  • @Prince feel free to contact me on Twitter (see the link on my profile). If you need to endorse me, you can use CommerceHero: commercehero.io/raphaelpetrini Jan 26, 2017 at 10:34

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.