3

是否可以创建一个将两个选项卡输出到发布屏幕的模块,或者我是否有两个创建另一个模块来创建我的第二个选项卡或只是另一个 tab.file.php 文件?

代码

文件: upd.my_module.php

class My_module_upd {
    var $version = '1.0';

    public function __construct(){
        $this->EE =& get_instance();
    }

    public function install(){
    $this->EE->load->dbforge();

    $data = array(
            'module_name' => 'My Module',
            'module_version' => $this->version,
            'has_cp_backend' => 'y',
            'has_publish_fields' => 'y'
    );

    $this->EE->db->insert('modules', $data);
    return true;
    }

    public function tabs(){
    $tabs['tab_1'] = array(
        'field_1'   => array(
                            'visible'       => TRUE,
                            'collapse'      => FALSE,
                            'htmlbuttons'   => TRUE,
                            'width'         => '100%'
                            ),

        'field_2'       => array(
                            'visible'       => TRUE,
                            'collapse'      => FALSE,
                            'htmlbuttons'   => TRUE,
                            'width'         => '100%'
                            )
            );

    $tabs['tab_2'] = array(
            'field_1'   => array(
                    'visible'       => TRUE,
                    'collapse'      => FALSE,
                    'htmlbuttons'   => TRUE,
                    'width'         => '100%'
                ),
            );

    return $tabs;   
    }

}

文件: tab.my_module.php

class My_module_tab {
public function __construct(){
    $this->EE =& get_instance();
}

public function publish_tabs($channel_id, $entry_id = ''){
    $settings = array(
            'field_1' => array(
                    'field_id'              => 'field_1',
                    'field_label'           => 'Field 1',
                    'field_type'            => 'text',
                    'field_required'        => 'n',
                    'field_data'            => '',
                    'field_text_direction'  => 'ltr',
                    'field_maxl'            => 100,
                    'field_instructions'    => '',
            ),
            'field_2'   => array(
                    'field_id'              => 'field_2',
                    'field_label'           => 'Field 2',
                    'field_type'            => 'text',
                    'field_required'        => 'n',
                    'field_data'            => '',
                    'field_text_direction'  => 'ltr',
                    'field_maxl'            => 100,
                    'field_instructions'    => '',
            ),
    );

    return $settings;
    }
 }

在 My_module_upd->tabs() 方法中,它看起来可以在数组中声明多个选项卡,但 My_module_tab 类似乎只适合控制一个选项卡。谁能指出我正确的方向?

4

0 回答 0