Я создаю модуль Magento, чтобы можно было сообщать о товарах. Я сделал переднюю часть хорошо, и все там работает.
Я пришел, чтобы создать админку для модуля, и у меня много проблем. Когда я нажимаю пункт меню для своего модуля (Каталог> Сообщенные продукты), он отображает интерфейс веб-сайта. (URL-адрес выглядит как "domain.com/index.php/admin/reported_products/adminhtml/key/76f4724a69.../"). Это отображает страницу 404.
Я пробовал много вариантов действия пункта меню, но ничего не помогло. Я также изменил front_name
под узлом admin
, но ничего: /
Я постараюсь представить файлы в хорошем порядке ...
приложение / код / локальные / Tbe / Report / etc / config.xml
<modules>
<Tbe_Report>
<version>0.1.0</version>
</Tbe_Report>
</modules>
<global>
<helpers>
<report>
<class>Tbe_Report_Helper</class>
</report>
</helpers>
<blocks>
<report>
<class>Tbe_Report_Block</class>
</report>
</blocks>
<models>
<report>
<class>Tbe_Report_Model</class>
<resourceModel>report_mysql4</resourceModel>
</report>
<report_mysql4>
<class>Tbe_Report_Model_Mysql4</class>
<entities>
<report>
<table>report</table>
</report>
</entities>
</report_mysql4>
</models>
<resources>
<report_setup>
<setup>
<module>Tbe_Report</module>
</setup>
<connection>
<use>core_setup</use>
</connection>
</report_setup>
<report_write>
<connection>
<use>core_write</use>
</connection>
</report_write>
<report_read>
<connection>
<use>core_read</use>
</connection>
</report_read>
</resources>
</global>
<frontend>
<routers>
<report>
<use>standard</use>
<args>
<module>Tbe_Report</module>
<frontName>report</frontName>
</args>
</report>
</routers>
<layout>
<updates>
<report>
<file>report.xml</file>
</report>
</updates>
</layout>
</frontend>
<adminhtml>
<routers>
<report>
<use>admin</use>
<args>
<module>Tbe_Report</module>
<frontName>reported_products</frontName>
</args>
</report>
</routers>
<admin>
<routers>
<adminhtml>
<args>
<modules>
<Tbe_Report after="Mage_Adminhtml">Tbe_Report</Tbe_Report>
</modules>
</args>
</adminhtml>
</routers>
</admin>
</adminhtml>
app/code/local/Tbe/Report/etc/adminhtml.xml
<?xml version="1.0"?>
<config>
<menu>
<catalog translate="title" module="report">
<title>Catalog</title>
<sort_order>30</sort_order>
<children>
<report>
<title>Reported Products</title>
<sort_order>100</sort_order>
<action>adminhtml/reported_products/reported/</action>
</report>
</children>
</catalog>
</menu>
<acl>
<resources>
<admin>
<children>
<tbe translate="title" module="report">
<title>View Reported Products</title>
<sort_order>1</sort_order>
</tbe>
</children>
</admin>
</resources>
</acl>
</config>
приложение / код / ядро / локальные / Tbe / Отчет / контроллеры / ReportedController.php
class Tbe_Report_ReportedController extends Mage_Adminhtml_Controller_Action {
public function indexAction() {
$this->loadLayout();
$this->renderLayout();
}
}
Да, у меня есть пустой Data.php в Tbe / Report / Helpers /
Любая помощь приветствуется.
ОБНОВЛЕНИЕ
Мне удалось заставить его работать (несколько). Единственная проблема сейчас - это узел <action>
в adminhtml.xml.
Если я НЕ добавляю к действию adminhtml
, страница отображается, показывая верхний и нижний колонтитулы администратора (я еще не создавал никакого контента). Однако URL-адрес не содержит / admin. Вместо этого URL-адрес выглядит следующим образом: http://domain.com/index.php/reported_products/reported/key/88bf4.../ ".
Если я добавлю к действию adminhtml
, он отобразит верхний и нижний колонтитулы интерфейса, но перейдет к правильному URL-адресу "http://domain.com/index.php/admin/reported_products/reported/key/88bf4.../".
Я бы очень хотел, чтобы URL-адрес был с / admin. Вот мой обновленный код:
приложение / код / локальные / Tbe / Report / etc / config.xml
<?xml version="1.0"?>
<config>
...
<!-- NOTHING HAS CHANGED HERE -->
<!-- I HAVE GOTTEN RID OF THE <adminhtml> NODE -->
<frontend>
<routers>
<report>
<use>standard</use>
<args>
<module>Tbe_Report</module>
<frontName>report</frontName>
</args>
</report>
</routers>
<layout>
<updates>
<report>
<file>report.xml</file>
</report>
</updates>
</layout>
</frontend>
<admin>
<routers>
<tbe_report>
<use>admin</use>
<args>
<module>Tbe_Report</module>
<frontName>reported_products</frontName>
<modules>
<Tbe_Report after="Mage_Adminhtml">Tbe_Report_Reported</Tbe_Report>
</modules>
</args>
</tbe_report>
</routers>
</admin>
</config>
приложение / код / локальные / Tbe / Report / etc / adminhtml.xml
<?xml version="1.0"?>
<config>
<menu>
<catalog translate="title" module="report">
<title>Catalog</title>
<sort_order>30</sort_order>
<children>
<report>
<title>Reported Products</title>
<sort_order>100</sort_order>
<action>adminhtml/reported_products/reported/index</action>
</report>
</children>
</catalog>
</menu>
...
</config>
приложение / код / локальный / Tbe / Report / controllers / ReportedController.php
class Tbe_Report_ReportedController extends Mage_Adminhtml_Controller_Action {
public function indexAction() {
$this->loadLayout();
$this->renderLayout();
}
}