I'm creating a widget to display ratings. (Already created -> activated -> added in a page)

Calling this widget by {{widget type="widgetreviewtab/list"}} on a cms page named sample

Now when access http://site.com/custom.html it's empty.

Below is my WidgetReviewTab/Block/List.php where i'm trying to get rating lists.

class Review_WidgetReviewTab_Block_List extends Mage_Core_Block_Abstract implements Mage_Widget_Block_Interface
    protected function _toHtml()
        $html = $this->getChildHtml('review_list');
        return $html;


If i use $html = 'custom text'; i'm getting result as custom text so widget's function is fine.

Is it proper to call $this->getChildHtml('review_list'); in widget.

I think i'm missing something ? Did any one have any idea to make it work ?

  • 1
    Do you have child block review_list defined in layout xml for Review_WidgetReviewTab_Block_List? If not you need to define it. Feb 26, 2014 at 12:00
  • No i'm not. I'm a newbie to magento. Can you plz elaborate the process. Feb 26, 2014 at 12:05
  • Can you describe in question how you call your Review_WidgetReviewTab_Block_List block? Feb 26, 2014 at 12:06
  • Description got updated. Have a look Feb 26, 2014 at 12:13
  • Do you want to display a list of all reviews or only for particular product? Feb 27, 2014 at 17:01

1 Answer 1


Widgets are independent entities apart from the whole layout XML system. So calling the $this->getChildHtml() method, which depends on layout XML, will not work in this case.

When you use $this->getChildHtml('review_list') that actually means that somewhere in the layout XML a 'review_list' block is defined as a child of the current block. That is not the case here, so lets forget the getChildHtml for now.

When you create a widget in the content through a widget directive, thats the {{widget..}} thingy you already talked about in your question, it is being parsed by a template filter.

This means that all logic for building up the content should be present in the Review_WidgetReviewTab_Block_List. A proper widget also needs a widget.xml in your module. In this xml file you can configure default settings but also define for instance which template should be used to render your widget. I attached a example at the bottom of my answer.

Displaying ratings of any kind means you probably need to load a helper or model via your widget block to get the needed data from the database.

A good tutorial to start building widgets: https://www.magentocommerce.com/knowledge-base/entry/tutorial-creating-a-magento-widget-part-1

Widget example:

<?xml version="1.0"?>
   <example type="review_widgetreviewtab/list">
       <name>Widget name</name>
       <description>Widget descriptoin</description>
            <label>Setting name</label>

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.