【问题标题】:Magento - Adminhtml new custom Tab in the config section is not showing upMagento - 配置部分中的 Adminhtml 新自定义选项卡未显示
【发布时间】:2015-02-05 21:36:06
【问题描述】:

我正在使用 Magento 1.9.0.1,现在我正在开发一个新的扩展,我想在管理面板中添加带有标签的新模块。

这是我到目前为止所做的:

/app/code/community/VivasIndustries/SmsNotification/etc/config.xml:

<?xml version="1.0"?>
<config>
  <modules>
    <VivasIndustries_SmsNotification>
      <version>0.1.0</version>
    </VivasIndustries_SmsNotification>
  </modules>
  <global>
    <models>
        <smsnotification>
            <class>VivasIndustries_SmsNotification_Model</class>
        </smsnotification>
    </models>  
    <events>
        <sales_order_save_after>
            <observers>
                <vivasindustries_smsnotification>
                    <class>smsnotification/observer</class>
                    <method>orderSaved</method>
                </vivasindustries_smsnotification>
            </observers>
        </sales_order_save_after>
    </events>
  </global>
  <adminhtml>
    <acl>
        <resources>
            <all>
                <title>Allow Everything</title>
            </all>
            <admin>
                <children>
                    <system>
                        <children>
                            <config>
                                <children>
                                    <vivas>
                                        <title>Vivas - All</title>
                                    </vivas>
                                </children>
                            </config>
                        </children>
                    </system>
                </children>
            </admin>
        </resources>
    </acl>
</adminhtml>
</config>  

这是我所拥有的: /app/code/community/VivasIndustries/SmsNotification/etc/system.xml

<?xml version="1.0" encoding="UTF-8"?>
<config>
    <tabs>
        <vivas translate="label" module="vivasindustries_smsnotification">
            <label>Vivas Extensions</label>
            <sort_order>100</sort_order>
        </vivas>
    </tabs>
    <sections>
        <vivas translate="label" module="vivasindustries_smsnotification">
            <label>Extension Options</label>
            <tab>vivas</tab>
            <sort_order>1000</sort_order>
            <show_in_default>1</show_in_default>
            <show_in_website>1</show_in_website>
            <show_in_store>1</show_in_store>

            <groups>
                <vivas_group translate="label" module="vivasindustries_smsnotification">
                    <label>My Extension Options</label>
                    <frontend_type>text</frontend_type>
                    <sort_order>1000</sort_order>
                    <show_in_default>1</show_in_default>
                    <show_in_website>1</show_in_website>
                    <show_in_store>1</show_in_store>

                    <fields>
                        <vivas_input translate="label">
                            <label>My Input Field: </label>
                            <comment>My Comment</comment>
                            <frontend_type>text</frontend_type>
                            <sort_order>20</sort_order>
                            <show_in_default>1</show_in_default>
                            <show_in_website>1</show_in_website>
                            <show_in_store>1</show_in_store>
                        </vivas_input>
                        <vivas_select translate="label">
                            <label>My Dropdown: </label>
                            <comment>Source model provider Magento's default Yes/No values</comment>
                            <frontend_type>select</frontend_type>
                            <sort_order>90</sort_order>
                            <show_in_default>1</show_in_default>
                            <show_in_website>1</show_in_website>
                            <show_in_store>1</show_in_store>
                            <source_model>adminhtml/system_config_source_yesno</source_model>
                        </vivas_select>
                    </fields>
                </vivas_group>
            </groups>
        </vivas>
    </sections>
</config>

这是我的内容:/app/code/community/VivasIndustries/SmsNotification/Helper/Data.php:

<?php
class VivasIndustries_SmsNotification_Helper_Data extends Mage_Core_Helper_Abstract 
{

}

完成此操作后,我在打开管理面板时收到以下错误:

致命错误:在第 547 行的 /home/superweb/public_html/store/app/Mage.php 中找不到类“Mage_Vivasindustries_Smsnotification_Helper_Data”

当我将文件夹名称 SmsNotification 更改为 Smsnotification 时,此错误消失了,但系统->配置中有任何新选项卡...

那么你们能帮我在管理面板中创建一个新标签吗?

提前致谢!

【问题讨论】:

    标签: magento admin adminhtml


    【解决方案1】:

    您忘记在config.xml 中为您的模块定义助手别名。它应该与模型的形式相同:

      <global>
        <helpers>
            <smsnotification>
                <class>VivasIndustries_SmsNotification_Helper</class>
            </smsnotification>
        </helpers>
        ...
    

    另外,在指定用于翻译的模块时,您必须在system.xml 中使用相同的别名:

    module="smsnotification"
    

    解释发生了什么: Magento 没有找到别名为“vivasindustries_smsnotification”的助手,所以它回退到Mage 命名空间和带有大写字母的给定别名作为模块(不,我从未见过这样的情况,这本来是理想的行为,但这就是它的工作原理)。这会导致 Mage_Vivasindustries_Smsnotification_Helper_Data 作为辅助类名称而无法找到。

    作为一般规则:如果 Magento 尝试从您的模块中加载带有“Mage_”前缀的类,您的模块配置要么不完整、有错误,要么被旧版本和配置缓存缓存必须清除。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-09-09
      • 2012-02-18
      相关资源
      最近更新 更多