php - 如何将左侧边栏中的自定义选项卡添加到 magento 模块管理部分中的自定义页面?

标签 php magento magento-1.7

我是 Magento 的新手,4 天前才开始使用 Magento,但我接到了开发 Magento 扩展 的任务。所以我正在通过互联网阅读并创建它。

现在我遇到的问题是我想添加一个自定义的左侧边栏选项卡,就像在
System->Configuration 下一样。

我尝试了很多,但都没有成功。请帮我。

这是我的 config.xml

<?xml version="1.0"?>
<config>
<!-- turn on our module, required for install support -->
<modules>
<Gwb_Magecrmsync>
    <version>0.1.0</version>
</Gwb_Magecrmsync>
</modules>
<frontend>
<routers>
    <magecrmsync>
        <use>standard</use>
        <args>
            <module>Gwb_Magecrmsync</module>
            <frontName>magecrmsync</frontName>
        </args>
    </magecrmsync>
</routers>
<layout>
    <updates>
        <magecrmsync>
            <file>adminhtml.xml</file>
        </magecrmsync>
    </updates>
</layout>
</frontend>
<admin>
<routers>
    <magecrmsync>
        <use>admin</use>
        <args>
            <module>Gwb_Magecrmsync</module>
            <frontName>magecrmsync</frontName>
        </args>
    </magecrmsync>
</routers>
</admin>
<adminhtml>
<menu>
    <menu1 translate="title" module="magecrmsync">
        <title>Synchronize</title>
        <sort_order>999</sort_order>
        <children>
            <menuitem1 module="magecrmsync">
                <title>Customers</title>
                <action>magecrmsync/adminhtml_magecrmsync</action>
            </menuitem1>
            <menuitem2 module="magecrmsync">
                <title>Orders</title>
                <action>magecrmsync/adminhtml_magecrmsync</action>
            </menuitem2>
            <menuitem3 module="magecrmsync">
                <title>Products</title>
                <action>magecrmsync/adminhtml_magecrmsync</action>
            </menuitem3>
        </children>
    </menu1>
</menu>
<acl>
    <resources>
        <admin>
            <children>
                <menu1 translate="title" module="magecrmsync">
                    <title>Synchronize</title>
                    <sort_order>999</sort_order>
                    <children>
                        <menuitem1>
                            <title>Customers</title>
                        </menuitem1>
                        <menuitem2>
                            <title>Orders</title>
                        </menuitem2>
                        <menuitem3>
                            <title>Products</title>
                        </menuitem3>
                    </children>
                </menu1>
            </children>
        </admin>
    </resources>
</acl>
</adminhtml>
<global>
<!-- turn on models -->
<models>
    <magecrmsync>
        <class>Gwb_Magecrmsync_Model</class>
        <resourceModel>Magecrmsync_mysql4</resourceModel>
    </magecrmsync>
</models>
<!-- turn on models -->

<!-- turn on database connections -->
<resources>
<!-- setup is needed for automatic installation -->
    <magecrmsync_setup>
        <use>default_setup</use>
    </magecrmsync_setup>
    <magecrmsync_write>
        <use>default_write</use>
    </magecrmsync_write>
    <magecrmsync_read>
        <use>default_read</use>
    </magecrmsync_read>
</resources>

<blocks>
    <magecrmsync>
        <class>Gwb_Magecrmsync_Block</class>
    </magecrmsync>
</blocks>

<helpers>
    <magecrmsync>
        <class>Gwb_Magecrmsync_Helper</class>
    </magecrmsync>
</helpers>

<layout>
    <magecrmsync>
        <file>adminhtml.xml</file>
    </magecrmsync>
</layout>

</global>
</config>

请告诉我哪里遗漏了一些不允许我在自定义页面左侧添加选项卡的内容。如果我有任何错误,请纠正我。


编辑
这是我的 system.xml 文件。这让我可以在 System->Configuration 下添加自定义选项卡,但我希望它在我的自定义页面上,该页面与配置菜单分开。

<?xml version="1.0"?>
<config>
<tabs>
    <sidetab translate="label" module="magecrmsync">
        <label>My Custom Tab</label>
        <sort_order>200</sort_order>
    </sidetab>
</tabs>
<sections>
    <sidetab translate="label" module="magecrmsync">
        <class>separator-top</class>
        <label>My Tab</label>
        <tab>sidetab</tab>
        <sort_order>100</sort_order>
        <show_in_default>1</show_in_default>
        <show_in_website>1</show_in_website>
        <show_in_store>1</show_in_store>
        <groups>
            <sidetab_option translate="label">
                <label>sysem Tab Options</label>
                <frontend_type>text</frontend_type>
                <sort_order>10</sort_order>
                <show_in_default>1</show_in_default>
                <show_in_website>1</show_in_website>
                <show_in_store>1</show_in_store>
                <fields>
<registration_mode translate="label"> <label>On New User Signup</label>
                        <frontend_type>select</frontend_type>
                            <source_model>adminhtml/system_config_source_yesno</source_model>
                        <sort_order>1</sort_order>
                        <show_in_default>1</show_in_default>
                        <show_in_website>1</show_in_website>
                        <show_in_store>1</show_in_store>
                    </registration_mode>
<forget_mode translate="label">
                        <label>Send Email on Forget Password</label>
                        <frontend_type>select</frontend_type>
                            <source_model>adminhtml/system_config_source_yesno</source_model>
                        <sort_order>1</sort_order>
                        <show_in_default>1</show_in_default>
                        <show_in_website>1</show_in_website>
                        <show_in_store>1</show_in_store>
                    </forget_mode>
<purchase_mode translate="label">
                        <label>Send Email On Product Purchase</label>
                        <frontend_type>select</frontend_type>
                            <source_model>adminhtml/system_config_source_yesno</source_model>
                        <sort_order>1</sort_order>
                        <show_in_default>1</show_in_default>
                        <show_in_website>1</show_in_website>
                        <show_in_store>1</show_in_store>
                    </purchase_mode>
                </fields>
</sidetab_option>
        </groups>
    </sidetab>
</sections>
</config>


我的 Controller 代码:

<?php
class Gwb_Magecrmsync_Adminhtml_MagecrmsyncController extends     Mage_Adminhtml_Controller_Action
{
public function indexAction()
{
    $this->loadLayout()
         ->_setActiveMenu('menu1')
         ->_addBreadcrumb(Mage::helper('adminhtml')->__('Synchronize Data'), Mage::helper('adminhtml')->__('Synchronize Data'))
         ->_title($this->__('Synchronize Data'));

    $block = $this->getLayout()->createBlock(
        'Mage_Core_Block_Template',
        'my_block_name_here',
        array('template' => 'magecrmsync/mainblock.phtml')
    );
    $this->getLayout()->getBlock('content')->append($block);

    $this->renderLayout();
}

}

我想像这样在我的页面上添加标签:

Tabs like this image has on the left side on my page not on system->configuration page.

任何帮助将不胜感激,对我很有帮助。

谢谢 掠夺者

最佳答案

您似乎想在管理 Controller 中创建一个“左”和“主” block 。

$this->loadLayout();
$this->_addContent($this->getLayout()->createBlock('form/adminhtml_form_edit'))
            ->_addLeft($this->getLayout()->createBlock('form/adminhtml_form_edit_tabs'));
$this->renderLayout();


class Excellence_Form_Block_Adminhtml_Form_Edit_Tabs extends Mage_Adminhtml_Block_Widget_Tabs
{

  public function __construct()
  {
      parent::__construct();
      $this->setId('form_tabs');
      $this->setDestElementId('edit_form'); // this should be same as the form id define above
      $this->setTitle(Mage::helper('form')->__('Product Information'));
  }

  protected function _beforeToHtml()
  {
      $this->addTab('form_section', array(
          'label'     => Mage::helper('form')->__('Item Information'),
          'title'     => Mage::helper('form')->__('Item Information'),
          'content'   => $this->getLayout()->createBlock('form/adminhtml_form_edit_tab_form')->toHtml(),
      ));

      return parent::_beforeToHtml();
  }
}

参见 http://www.excellencemagentoblog.com/module-development-series-magento-admin-module-part3

enter image description here

$this->_addLeft($this->getLayout()
    ->createBlock('core/text')
    ->setText('<h1>Left Block</h1>'));

$block = $this->getLayout()
    ->createBlock('core/text')
    ->setText('<h1>Main Block</h1>');           
    $this->_addContent($block);

阅读更多@ http://alanstorm.com/magento_admin_controllers

关于php - 如何将左侧边栏中的自定义选项卡添加到 magento 模块管理部分中的自定义页面?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15293900/

相关文章:

php - Paypal Pro 不在 magento 中显示运输方式

magento - 在 Magento 结帐页面上显示错误消息(运输方式阶段)

magento-1.7 - magento 通知 : Array to string conversion lib\Varien\Data\Form\Element\Image. php 第 57 行

php - 如何在 magento 中获取页面标题?

php - 我正在尝试在表中添加一个下拉菜单框,其中包含从 mysql 获取的数据

php - 将mysql数据分成3列错误

php - 当客户在结帐期间注册时,结账和客户注册失败

magento - 处理您的请求时出错,错误日志记录号

php - MySql一般错误: 2053

php - 查找前 5 条记录的 Eloquent 查询