在Magento前端添加日历

时间:2011-04-20 07:20:56

标签: magento

如何在自定义表单的Magento前端添加日历弹出窗口?

2 个答案:

答案 0 :(得分:2)

只需在indexAction()中添加此代码:

$this->loadLayout();
$blockCal = $this->getLayout()->createBlock(
    'Mage_Core_Block_Html_Calendar',
    'html_calendar',
    array('template' => 'page/js/calendar.phtml')
);

$this->getLayout()->getBlock('content')->append($blockCal);
$headBlock = $this->getLayout()->getBlock('head');

$headBlock->addJs('calendar/calendar.js');
$headBlock->addJs('calendar/lang/calendar-en.js');
$headBlock->addJs('calendar/calendar-setup.js');

答案 1 :(得分:1)

你也可以在这样的布局文件中定义它:

<reference name="head">
    <action method="addItem"><type>js_css</type><name>calendar/calendar-win2k-1.css</name><params/><!--<if/><condition>can_load_calendar_js</condition>--></action>
    <action method="addItem"><type>js</type><name>calendar/calendar.js</name><!--<params/><if/><condition>can_load_calendar_js</condition>--></action>
    <action method="addItem"><type>js</type><name>calendar/calendar-setup.js</name><!--<params/><if/><condition>can_load_calendar_js</condition>--></action>
</reference>