Php Magento:将带有子块的块添加到cms_index_index

Php Magento:将带有子块的块添加到cms_index_index,php,magento,block,Php,Magento,Block,也许我走错了方向,但我对Magento还很陌生,我不知道还有什么更好的。我试图在我的首页添加一个块,我相信这是cms_index_index(正确吗?)。这项工作: <cms_index_index> <reference name="content"> <block type="core/template" name="start_recs" as="start_recs" template="path/to/recommendations

也许我走错了方向,但我对Magento还很陌生,我不知道还有什么更好的。我试图在我的首页添加一个块,我相信这是cms_index_index(正确吗?)。这项工作:

<cms_index_index>
    <reference name="content">
        <block type="core/template" name="start_recs" as="start_recs" template="path/to/recommendations.phtml"></block>
    </reference>
</cms_index_index>
但这会导致以下错误:

Fatal error: Call to a member function setData() on a non-object in /home/www/project/path/to/recommendations.phtml on line 125

我就是不明白为什么。为什么getChild(“addtocart_special”)是非对象?我错过了什么

您是在创建自定义扩展名还是将代码放在哪个xml文件中?在app/design/frontend/themename/default/layout/local.xml中
$this->getChild('addtocart_special')->setData('product', $_product);
echo $this->getChildHtml('addtocart_special', false);
Fatal error: Call to a member function setData() on a non-object in /home/www/project/path/to/recommendations.phtml on line 125