Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
177 views
in Technique[技术] by (71.8m points)

how to create multiple tab in magento custom module?

How to create multiple horizontal and vertical tab like category page at admin side and save data in DB?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

I have idea about adding vertical tab in form, just put below code in your tabs.php file of your module in _beforeToHtml() function

 $this->addTab('tabid', array(
            'label'     => Mage::helper('modulename')->__('Name of tab'),
            'class'     => 'ajax',
            'url'       => $this->getUrl('*/*/action controller name', array('_current' => true)),
        ));

just give tabid whatever you want and in url give action name add this function also in your tabs.php file for handle tab update and call $this->_updateActiveTab(); in _beforeToHtml() function

protected function _updateActiveTab()
{
    $tabId = $this->getRequest()->getParam('tab');
    if ($tabId) {
        $tabId = preg_replace("#{$this->getId()}_#", '', $tabId);
        if ($tabId) {
            $this->setActiveTab($tabId);
        }
    }
    else {
       $this->setActiveTab('form_section'); 
    }
}

add action in controller something like this

public function yourAction() 
{
    $id = (int) $this->getRequest()->getParam('id');
    $model = Mage::getModel('modulename/modulename');

    if ($id) {
        $model->load($id);
    }

    Mage::register('modulename_data', $model);

    $this->getResponse()->setBody($this->getLayout()
      ->createBlock('modulename/adminhtml_modulename_edit_tab_tabid')->toHtml());
}  

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...