联系电话:0755-27515592
最新动态:

Magento教程

如何向Magento管理后端页面添加日期选取器

点击数:12722015-07-21 10:57:42 来源: 外贸网站建设,深圳外贸网站建设,深圳网站建设,外贸商城网站制作-亿恩科技

新闻摘要:在本教程中,我们将去通过如何添加日期选取器toMagento 管理后端配置页。那里是没有直接的模型,可以调用以添加日期选取器。然而,这些简单的步骤将允许您将添加到您的 Magento 网站的后端

在本教程中,我们将去通过如何添加日期选取器toMagento 管理后端配置页。那里是没有直接的模型,可以调用以添加日期选取器。然而,这些简单的步骤将允许您将添加到您的 Magento 网站的后端的日期选取器

how to add date picker in magento


第 1 步。

编辑 system.xml ,创建的新字段,如下所示:

 
1
2
3
4
5
6
7
8
9
10
<my_date translate="label comment">
<label>Expire On</label>
<frontend_type>text</frontend_type> <!-- Set the frontend type as Text -->
<frontend_model>MODULE_NAME/adminhtml_system_config_date</frontend_model> <!-- Specify our custom model -->
<sort_order>4</sort_order>
<show_in_default>1</show_in_default>
<show_in_website>1</show_in_website>
<show_in_store>1</show_in_store>
<comment>Set the expiry date for the Feature Tour</comment>
</my_date>

 

一步2.

在路径上创建新的模型文件: app\code\local\ < 命名空间 > \ < 模块 > \Block\Adminhtml\System\Config\Date.php

 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
<?php
class Arvtour_Tour_Block_Adminhtml_System_Config_Date extends Mage_Adminhtml_Block_System_Config_Form_Field
{
    protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
    {
        $date = new Varien_Data_Form_Element_Date;
        $format = Mage::app()->getLocale()->getDateFormat(Mage_Core_Model_Locale::FORMAT_TYPE_SHORT);
 
        $data = array(
            'name'      => $element->getName(),
            'html_id'   => $element->getId(),
            'image'     => $this->getSkinUrl('images/grid-cal.gif'),
        );
        $date->setData($data);
        $date->setValue($element->getValue(), $format);
        $date->setFormat(Mage::app()->getLocale()->getDateFormat(Mage_Core_Model_Locale::FORMAT_TYPE_SHORT));
        $date->setForm($element->getForm());
 
        return $date->getElementHtml();
    }
}


【责任编辑:(Top) 返回页面顶端
贴心
全国7×24小时客服热线
安全
病毒杀除率高于99%
稳定
网站可用性高于99.9%
实力
服务68家上市企业及集团公司
亿恩科技手机站
关注亿恩科技微信

亿恩科技—企业信息化一站式服务专家


Copyright © 2008- 深圳市亿恩科技有限公司版权所有 粤ICP备15056041号

联系我们 | 常见问题 | 在线留言 | 支付方式 | 软件开发 | 我的观点 | 资质荣誉 | 服务流程