php - Magento: add block with child blocks to cms_index_index -


maybe i'm going wrong way, i'm quite new magento , don't know better. i'm trying add block front page, believe cms_index_index (is correct?). works:

<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> 

but in recommendations.phtml, want reference block, addtocart_special.phtml. did in other catalog blocks , worked fine, somehow cannot make work in cms_index_index. tried this:

<cms_index_index>     <reference name="content">         <block type="core/template" name="start_recs" as="start_recs" template="path/to/recommendations.phtml">             <action method="setblockid"><block_id>start-recs</block_id></action>             <block type="core/template" name="addtocart_special" as="addtocart_special" template="catalog/product/view/addtocart_special.phtml">             </block>         </block>     </reference> </cms_index_index> 

and in recommendations.phtml, call addtocart_special this:

$this->getchild('addtocart_special')->setdata('product', $_product); echo $this->getchildhtml('addtocart_special', false); 

but results in following error:

fatal error: call member function setdata() on non-object in /home/www/project/path/to/recommendations.phtml on line 125 

i don't why. why getchild('addtocart_special') non-object? missing?


Comments

Popular posts from this blog

java - Date formats difference between yyyy-MM-dd'T'HH:mm:ss and yyyy-MM-dd'T'HH:mm:ssXXX -

c# - Get rid of xmlns attribute when adding node to existing xml -