Php Magento:模块中的自定义左选项卡菜单
我已经知道如何将实际的选项卡项添加到自定义模块中,但是我无法知道如何像系统模块那样添加绿色的部分标题。使用system.xml文件将您自己的添加到系统模块本身并不困难,但是如何将一个添加到自己的模块菜单中呢 编辑:添加了我用于选项卡的代码作为参考。正在扩展的区块的文档也发布在下面。 这是为了添加选项卡,但是它们的部分标题呢Php Magento:模块中的自定义左选项卡菜单,php,magento,Php,Magento,我已经知道如何将实际的选项卡项添加到自定义模块中,但是我无法知道如何像系统模块那样添加绿色的部分标题。使用system.xml文件将您自己的添加到系统模块本身并不困难,但是如何将一个添加到自己的模块菜单中呢 编辑:添加了我用于选项卡的代码作为参考。正在扩展的区块的文档也发布在下面。 这是为了添加选项卡,但是它们的部分标题呢 $this->addTab('custom_assigned_tab1_id_name', array( 'label' =>
$this->addTab('custom_assigned_tab1_id_name', array(
'label' => Mage::helper('coffefreakhelper1')->__('Custom tab1 here'),
'title' => Mage::helper('coffefreakhelper1')->__('My custom tab1 title here'),
'content' => 'Some content here. We could add direct string here, or we can use something like $this->getLayout()->createBlock("adminhtml/cms_page_edit_tab_main")->toHtml()',
'active' => true
));
编辑:解决了
在查看了系统块之后,我注意到他们制作了一个特定的模板和一些实用方法来处理widget类。因此,知道了这一点,我扩展了Mage_Adminhtml_Block_System_Config_选项卡,而不是Mage_Adminhtml_Block_小部件类。下面我有一个测试的例子
class Inchoo_CoffeeFreak_Block_ShowTabsAdminBlock extends Mage_Adminhtml_Block_System_Config_Tabs {
protected $_tabs;
public function __construct() {
parent::__construct();
$this -> setId('test_config_tabs');
$this -> setTitle("Test Tab Page");
$this -> setTemplate('system/config/tabs.phtml');
}
protected function _beforeToHtml() {
for($tab = 1; $tab < 4; $tab++){
$tabCode = 'tab_' . $tab;
$tabTitle = "Tab " . $tab;
$this -> addTab($tabCode, array("label" => $tabTitle, "class" => ""));
for($section = 1; $section < 4; $section++){
$sectionCode = "section_" . $tab . "_" . $section;
$sectionTitle = "Section " . $section;
$this -> addSection($sectionCode, $tabCode, array('class' => '', 'label' => $sectionTitle, 'url' => '', ));
}
}
$this -> setLastSections();
return parent::_beforeToHtml();
}
public function setLastSections() {
foreach ($this->getTabs() as $tab) {
$sections = $tab -> getSections();
if ($sections) {
$sections -> getLastItem() -> setIsLast(true);
}
}
}
}
结果如下图所示
I扩展类将选项卡作为主要部分标题。它将每个子选项卡分组分开。子选项卡称为“节”。我的测试脚本只是循环并创建3个选项卡,每个选项卡有3个部分 我在我的主要帖子中添加了一个带有答案的编辑。还为其他想要使用它的人提供了一个测试片段 同样值得一提的是,我的样板模块是由Inchoo创建的,可以在下面的链接中查看。我用上面粘贴的代码替换了他们的标签代码。结果是一个很好的菜单,其中包含带有标题的分组选项卡