Take the 2-minute tour ×
Magento Stack Exchange is a question and answer site for users of the Magento e-Commerce platform. It's 100% free, no registration required.

I am using Ajax to add to cart, so need to update the cart side bar.

I have try this code in controller to render the block.

Mage::app()->getLayout()->getBlockSingleton('page/html')->setTemplate("page/html/upper.phtml")->toHtml();

but it render the parent block and doesn't render the child blocks.

And layout file is

   <block type="core/text_list" name="upper" as="upper" template="page/html/upper.phtml">
       <block type="checkout/cart" name="top.cart" as="cart_overview">
            <action method="setCartTemplate"><value>checkout/topcart.phtml</value></action>
            <action method="setEmptyTemplate"><value>checkout/cart/cartEmpty.phtml</value></action>
            <action method="chooseTemplate"/>
            <action method="addItemRender"><type>simple</type><block>checkout/cart_item_renderer</block><template>checkout/cart/sidebar/default.phtml</template></action>
            <action method="addItemRender"><type>grouped</type><block>checkout/cart_item_renderer_grouped</block><template>checkout/cart/sidebar/default.phtml</template></action>
            <action method="addItemRender"><type>configurable</type><block>checkout/cart_item_renderer_configurable</block><template>checkout/cart/sidebar/default.phtml</template></action>
       </block>
   </block>

how can i render child block in controller.

Assist me.

share|improve this question
add comment

1 Answer 1

up vote 5 down vote accepted

Please try this code:-

$layout         = Mage::app()->getLayout();
 $block_header   = $layout->createBlock('block/block')->setTemplate('template_url');

 $block_links1  = $layout->createBlock('block/block','block_name')->setTemplate('template_url');
 $block_header->setChild('block_as',$block_links1);

 $block_links2  = $layout->createBlock('block/block','block_name')->setTemplate('template_url');
 $block_header->setChild('block_as',$block_links2);

 $block_links    = $layout->createBlock('block/block','block_name')->setTemplate('template_url');
 $block_header->setChild('block_as',$block_links);

 $block_links->addItemRender('configurable','checkout/cart_item_renderer_configurable','checkout/cart/sidebar/default.phtml');
 $slide = $block_header->toHtml();
share|improve this answer
    
Thanks for your answer.... –  Vijay S May 2 at 13:27
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.