如何在magento自定义模块中创建多个选项卡? [英] how to create multiple tab in magento custom module?
问题描述
如何在管理员端创建多个水平和垂直选项卡(如类别页面)并将数据保存在DB中?
How to create multiple horizontal and vertical tab like category page at admin side and save data in DB?
推荐答案
我有关于在窗体中添加垂直制表符的想法,只需在_beforeToHtml()函数的模块的tabs.php文件中的代码下面放置
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)),
));
只要给tabid任意名称,并在url中给动作名称添加此功能,也可以在tabs.php文件中添加此功能以更新句柄选项卡 并调用$ this-> _ updateActiveTab();在_beforeToHtml()函数中
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());
}
这篇关于如何在magento自定义模块中创建多个选项卡?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!