2011-12-06 82 views
10

我正在开发Magento 1.6中的自定义SMS模块。管理中的自定义Magento配置中的404错误

我已经设置了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错误出现...

+0

To f ind确切的错误:这为我工作http://pradhab.blogspot.com/2013/03/magento-404-error.html试试这个 –

+1

请不要提供“仅链接”的答案(如果页面会发生什么在远程站点被取下?)。如果外部内容相关,请将步骤/代码添加到您的答案中,并且可以引用该来源作为额外的注释。 – newfurniturey

回答

36

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> 
</...> 

添加你上面后,将需要注销并为完整的管理角色的用户重新登录,并明确添加此角色的自定义管理员用户角色。

+0

我放置了adminhtml.xml文件并按照您的指示操作。但直到它404错误。 –

+0

你可以在任何地方粘贴你的代码吗? – benmarks

+1

你是对的Ben,我的代码中有一些错误。现在它正在工作。谢谢你的帮助。 –

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在t他URL(当你点击你的选项卡上):

​​

此网址似乎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>