Ошибка 404 в пользовательской настройке Magento в admin
Я разрабатываю собственный модуль SMS в Magento 1.6.
Я установил файл 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...
Ответы
Ответ 1
Ошибка 404 в конфигурации системы часто означает, что есть проблема с ACL. Вероятно, вам не хватает соответствующего acl node в вашем файле 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>
</...>
После добавления выше вы должны выйти и войти в систему для пользователей с полной административной ролью и явно добавить эту роль к пользовательским ролям пользователя.
Ответ 2
Сделайте то, что сказал @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>
</...>
очистить кеш, выйти из системы администратора, войти в систему admin == работает
Совет. Если вы посмотрите на URL-адрес (если вы нажмете на свою вкладку):
/index.php/admin/system_config/edit/section/mymodulename_something/...
Этот 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>
Ответ 3
Не стоит недооценивать необходимость выхода из системы и последующего входа в систему после внесения изменений ACL. Даже если вы очистите кеш, вы все равно будете 404, пока не выйдете из системы и не войдете в систему.