【问题标题】:404 error in Custom Magento configuration in admin管理员中自定义 Magento 配置中的 404 错误
【发布时间】:2012-01-13 22:58:59
【问题描述】:

我正在 Magento 1.6 中开发自定义 SMS 模块。

我已经设置了system.xml 文件来管理相关的自定义配置字段。

菜单项出现了,但是当我单击它时,显示的是 404 错误页面,而不是预期的配置字段列表。

你能看到我的代码中有什么错误吗?

<config>
<tabs>
    <mynew_tab translate="label">
        <label>SMS Gateway Integration</label>
        <sort_order>100</sort_order>
    </mynew_tab>
</tabs>
<sections>
    <smsconfig  translate="label">
        <label>SMS Gateway Integration</label>
        <sort_order>200</sort_order>
        <show_in_default>1</show_in_default>
        <show_in_website>1</show_in_website>
        <show_in_store>1</show_in_store>
        <tab>mynew_tab</tab>
        <groups>
            <sms_group translate="label">
                <label>My Custom Configurations</label>
                <comment>This is example of custom configuration.</comment>
                <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>
                    <sms_enabled translate="label tooltip comment">
                        <label>Is Enabled</label>
                        <frontend_type>select</frontend_type>
                        <source_model>adminhtml/system_config_source_yesno</source_model>
                        <sort_order>0</sort_order>
                        <show_in_default>1</show_in_default>
                        <show_in_website>1</show_in_website>
                        <show_in_store>1</show_in_store>
                        <comment>Enable this module.</comment>
                    </sms_enabled>
                    <sms_username translate="label tooltip comment">
                        <label>Sender Email</label>
                        <frontend_type>text</frontend_type>
                        <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>
                        <comment>Username of the SMS gateway.</comment>
                    </sms_username>
                    <sms_password translate="label tooltip comment">
                        <label>Sender Email</label>
                        <frontend_type>text</frontend_type>
                        <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>
                        <comment>Password of the SMS gateway.</comment>
                    </sms_password>
                </fields>
            </sms_group>
        </groups>
    </smsconfig>
</sections>

根据 ben 的请求,我们放置了 adminhtml.xml 文件。我放置了 XML 文件的内容。

<config>
<acl>   
    <resources>
        <admin>
            <children>
                <system>
                    <children>
                        <config>
                            <children>
                                <sms translate="title" module="sms">
                                    <title>SMS Gateway Section</title>
                                </sms>
                            </children>
                        </config>
                    </children>
                </system>
           </children>
       </admin>
   </resources>
</acl>

但是直到 404 错误出现...

【问题讨论】:

  • 要找到确切的错误:这对我有用pradhab.blogspot.com/2013/03/magento-404-error.html试试这个
  • 请不要提供“仅链接”的答案(如果远程站点上的页面被删除会怎样?)。如果外部内容相关,请将步骤/代码添加到您的答案中,您可以引用源代码作为额外注释。

标签: magento adminhtml


【解决方案1】:

系统配置中的 404 错误通常意味着 ACL 存在问题。您可能在模块的 adminhtml.xml 文件中缺少适当的 acl 节点:

<acl>
    <resources>
        <admin>
            <children>
                <system>
                    <children>
                        <config>
                            <children>
                                <smsconfig> <!-- translate="title" module="sms_config" if appropriate and depending on config -->
                                    <title>Your Section</title>
</...>

添加上述内容后,您需要注销并重新登录以获得完整的管理员角色用户,并将此角色明确添加到自定义管理员用户角色。

【讨论】:

  • 我放置了 adminhtml.xml 文件并按照您的说明进行操作。但直到它出现 404 错误。
  • 你是对的 Ben,我的代码中有一些错误。现在它正在工作。感谢您的帮助。
  • 您必须断开连接才能生效。
  • &lt;sms_config&gt;应该是&lt;smsconfig&gt;,与sections下system.xml中使用的名称相同
  • 确实应该。已编辑。
【解决方案2】:

不要低估在更改 ACL 后注销然后重新登录的需要。即使您清除缓存,在您注销并重新登录之前,您仍然会出现 404。

【讨论】:

    【解决方案3】:

    按照@benmarks 所说的去做,并确保添加正确的孩子(在你的情况下)smsconfig

    (@benmarks 使用sms_config 而不是smsconfig

    <!-- namespace/modulename/etc/adminhtml.xml -->
    <acl>
        <resources>
            <admin>
                <children>
                    <system>
                        <children>
                            <config>
                                <children>
                                    <smsconfig> <!-- translate="title" module="sms_config" if appropriate and depending on config -->
                                        <title>Your Section</title>
    </...>
    

    清除缓存、管理员注销、管理员登录 == 有效

    提示:如果您收到 404,请查看网址(当您点击标签时):

    /index.php/admin/system_config/edit/section/mymodulename_something/...

    这个网址似乎 指向 mymodulename_something:

    <!-- namespace/modulename/etc/system.xml -->
    <?xml version="1.0"?>
    <config>
        <tabs>
            <mymodulename translate="label" module="mymodulename">
                <label>MyModuleName Awesome Label</label>
                <sort_order>1</sort_order>
            </mymodulename>
        </tabs>
        <sections>
            <mymodulename_something translate="label" module="mymodulename">
    <!-- ... -->
    

    所以你的 adminhtml.xml 看起来像:

    <!-- namespace/modulename/etc/adminhtml.xml -->
    <?xml version="1.0"?>
    <config>
        <acl>
            <resources>
                <admin>
                    <children>
                        <system>
                            <children>
                                <config>
                                    <children>
                                        <mymodulename_something translate="title" module="mymodulename">
                                            <title>have no idea where this is showing up btw</title>
                                        </mymodulename_something>
                                    </children>
                                </config>
                            </children>
                        </system>
                    </children>
                </admin>
            </resources>
        </acl>
    </config>
    

    【讨论】:

      猜你喜欢
      • 2018-12-29
      • 2011-08-17
      • 2013-06-15
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-05-06
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多