2

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
 ->getLayout()
 ->createBlock($widget->getType(),
 $widget->getTitle(),
 $widget->getWidgetParameters());
echo $widgetBlock->toHtml();

And

<?php
$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;
?>
asked Dec 29, 2016 at 11:13

1 Answer 1

1

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.

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

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.