【问题标题】:How to Use Time Picker in Joomla Compoent如何在 Joomla 组件中使用时间选择器
【发布时间】:2016-07-22 05:25:03
【问题描述】:

我新开发的 Joomla 组件。我想知道如何在我的 Joomla 组件中添加时间选择器。

【问题讨论】:

    标签: php joomla joomla3.0


    【解决方案1】:

    您可以在 Joomla 中创建自己的自定义字段类型。此示例适用于模块,但相同的过程适用于组件: 创建这个文件: /modules/mod_yourmodule/fields/datetime.php

    <?php // Check to ensure this file is included in Joomla! defined('_JEXEC') or die('Restricted access'); // Add CSS and JS    JHtml::stylesheet('http://netdna.bootstrapcdn.com/twitter-bootstrap/2.2.2/css/bootstrap-combined.min.css');    JHtml::stylesheet('http://tarruda.github.com/bootstrap-datetimepicker/assets/css/bootstrap-datetimepicker.min.css');JHtml::script('http://tarruda.github.com/bootstrap-datetimepicker/assets/js/bootstrap-datetimepicker.min.js');    jimport('joomla.form.formfield');    class JFormFieldDateTime extends JFormField {
    
    protected $type = 'DateTime';
    
    public function getInput() {
            return '<div class="well">'.
                    '<div id="datetimepicker2" class="input-append">'.
                        '<input data-format="MM/dd/yyyy HH:mm:ss PP" type="text"></input>'.
                        '<span class="add-on">'.
                          '<i data-time-icon="icon-time" data-date-icon="icon-calendar"></i>'.
                        '</span>'.
                      '</div>'.
                    '</div>'.
                    '<script type="text/javascript">'.
                      'jQuery(function() {'.
                        'jQuery("#datetimepicker2").datetimepicker({'.
                          'language: "en",'.
                          'pick12HourFormat: true'.
                        '});'.
                      '});'.
                    '</script>';
    }  }
    

    【讨论】:

    • 为什么要导入另一个 Bootstrap 实例?您可能还希望正确显示您的代码,因为其中一半已被注释掉。
    【解决方案2】:

    显示日历控件字段:

    calendar($value, $name, $id, $format= '%Y-%m-%d', $attribs=null)
    
    
    $value=>The date value,$name=>The name of the text field,$id=>The id of the text field,$format=>'%Y-%m-%d'  The date format,$attribs=>null  Additional html attributes,$value=>The date value,$name=> The name of the text field,$id=>            The id of the text field,$format=>'%Y-%m-%d' The date format,$attribs=>null   Additional html attributes
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2012-08-11
      • 2015-12-17
      • 1970-01-01
      • 2020-11-24
      • 1970-01-01
      • 1970-01-01
      • 2014-11-20
      相关资源
      最近更新 更多