I can't figure why my block is not displayed as expected. Here what i've done to debug this. First of all my layout:

<vendor_contest_contest_index translate="label" module="vendor_contest">
    <label>Contests list</label>
    <update handle="page_one_column" />
    <reference name="content">
        <block type="vendor_contest/contest_list" name="contest_list" template="vendor_contest/contest/list.phtml" />
<vendor_contest_contest_view translate="label" module="vendor_contest">
    <label>Contest view page</label>
    <update handle="page_one_column" />
    <reference name="content">
        <block type="vendor_contest/contest_view" name="contest_view" template="vendor_contest/contest/view.phtml" >
            <block type="vendor_contest/contest_content" name="contest_content" template="vendor_contest/contest/content.phtml" />
            <block type="vendor_contest/contest_answer_list" name="contest.answer_list" as="contest_answers" template="vendor_contest/contest/answer/list.phtml" />
            <block type="vendor_contest/contest_answer_answered" name="contest.answer_answered" as="contest_answered" template="vendor_contest/contest/answer/answered.phtml" />

Here is the contest_view block :

public function getAnswersListView()
    return $this->getChildHtml('contest.answer_list');

public function getAlreadyAnsweredView()
    return $this->getChildHtml('contest.answer_answered');

public function hasCustomerAnswered()
    $answered = false;
    $contest = $this->getCurrentContest();
    $customer = Mage::getSingleton('customer/session')->getCustomer();
    $collection = Mage::getModel('vendor_contest/participation')->getCollection();
            ->addFieldToFilter('customer_id', $customer->getId())
            ->addFieldToFilter('contest_id', $contest->getId())
    if (count($collection)) {
        $answered = true;
    return $answered;

And my view.phtml

echo $this->getChildHtml('contest_content');
if ($this->hasCustomerAnswered()) {
     echo $this->getAlreadyAnsweredView();
} else {
    echo $this->getAnswersListView();

Here only the block contest_content is diplsayed. If i change the first line to

echo $this->getChildHtml();

All my blocks are displayed. That means there is no error in my block code, i guess. Both my system.log and error.log are empty.

If needed i can provide more files. Just tell me which one you'd like to see.

On my side i tried to debug this way : i went to


and i dumped $childName in it.

string(15) "contest_content" string(19) "contest.answer_list" string(23) "contest.answer_answered" 

And my three blocks are effectively displayed below.

I didnt manage to understand deeper why my block aren't displayed with the above snippets of code.

Thanks you all who'll take time to read this.

EDIT : here's my Content.php


class Vendor_Contest_Block_Contest_Content extends Vendor_Contest_Block_Contest_View


Notice the extends. Since basically block Content doesnt need anything more than View it felt right to me to extends Contest_View.

  • Could you post the content of your vendor_contest/contest_content block please ? Jan 15, 2016 at 9:39
  • @DigitalPianism i added it. Jan 15, 2016 at 9:44
  • What happens if you make this block extend Mage_Core_Block_Template instead ? Jan 15, 2016 at 9:45
  • 1
    No it didnt. I'll try to be more clear. As you can see in my layout i have 3 blocks depending of contest_view. When i call echo $this->getChildHtml('contest_content'); from my view.phtml the block is rendered. BUT when i do echo $this->getAnswersListView(); or echo $this->getAlreadyAnsweredView(); those blocks ARE NOT rendered. But a call to getChildHtml(); render them all. Does it make more sense to you ? Jan 15, 2016 at 9:52
  • 2
    Yes, clearer. Change your block name from contest.answer_list to answer_list in both your layout and your block function. Do the same for the contest.answer_answered block. I reckon the name does not match Magento standards. Jan 15, 2016 at 9:54

1 Answer 1


Thank to the help provided by @Digital Pianism in the comments I noticed getChildHtml() expects to be given an ALIAS block and not its name (if it exists). Don't be fooled by the variable name $childName in the core if you have to go through it.

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.