I have created Widget and want to call it from header.phtml enter image description here In this widget i have called Static block but widget not called.This widget have id 2 i have set code below please help me to correct this or give me another for id = "2"

$widget = Mage::getModel('cms/widget_block')->load('2');
                    $widgetBlock = $this
echo $widgetBlock->toHtml();


$filter = new Mage_Widget_Model_Template_Filter();
$_widget = $filter->filter('{{widget type="cms/widget_page_link" template="cms/widget/link/link_block.phtml" page_id="2"}}');
echo $_widget;


You can directly call a widget on header from admin panel create widget page.

Just click on Add Layout Update button and select page you want to display on from Display On dropdown,(here if you want to display on all page then select All Pages), then from Block Reference select Page Header (Or Page header with position) and then from Widget Options select your static block. Save the widget and check on frontend after clean cache.

| improve this answer | |
  • it's not display where i want – Ketan Borada Dec 29 '16 at 12:10
  • did you tried other option of header like Page Header, Primary, Central Column and Page Header, Primary, Left Column etc? – Piyush Dec 29 '16 at 12:14
  • yes but i want php code to display – Ketan Borada Dec 29 '16 at 12:16
  • I didn't get your point – Piyush Dec 29 '16 at 12:20
  • i mean i cant call exactly where i want by this method i want php code – Ketan Borada Dec 29 '16 at 12:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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