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:
<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" />
</reference>
</vendor_contest_contest_index>
<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" />
</block>
</reference>
</vendor_contest_contest_view>
</layout>
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();
$collection
->addFieldToFilter('customer_id', $customer->getId())
->addFieldToFilter('contest_id', $contest->getId())
->load();
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
app/code/core/Mage/Core/Block/Abstract.php
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
<?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.