[英]Magento custom module admin url returns to frontend and 404 error page
[英]Magento - Admin URL Shows Front End 404 (Csutom Module)
我正在创建一个Magento模块,以允许报告产品。 我已经做好了前端的工作,并且一切都在那儿进行。
我来为模块创建一个管理区域,遇到了很多麻烦。 当我单击我的模块的菜单项(目录>报告的产品)时,它将呈现网站的前端。 (通过“ domain.com/index.php/admin/reported_products/adminhtml/key/76f4724a69.../”获得了预期的网址)。 这将显示404页面。
我已经对菜单项的动作进行了很多尝试,但没有任何效果。 我还更改了admin
节点下的front_name
,但没有进行任何操作:/
我将尝试以良好的顺序显示文件...
应用程序/代码/本地/ Tbe /报告/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();
}
}
是的,我在Tbe / Report / Helpers /下确实有一个空白的Data.php。
任何和所有帮助表示赞赏。
我设法使其工作(某种程度上)。 现在唯一的问题是adminhtml.xml中的<action>
节点。
如果我不使用adminhtml
进行操作, adminhtml
渲染该页面,并显示admin的页眉和页脚(我尚未完成任何内容)。 但是,URL不包含/ admin。 该URL而是“ http://domain.com/index.php/reported_products/reported/key/88bf4.../ ”。
如果我确实使用adminhtml
,它将呈现前端页眉和页脚,但会转到正确的网址“ http://domain.com/index.php/admin/reported_products/reported/key/88bf4.../ ” 。
我真的希望URL与/ admin一起使用。 这是我更新的代码:
应用程序/代码/本地/ Tbe /报告/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>
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/index</action>
</report>
</children>
</catalog>
</menu>
...
</config>
应用程序/代码/本地/ Tbe /报告/控制器/ReportedController.php
class Tbe_Report_ReportedController extends Mage_Adminhtml_Controller_Action {
public function indexAction() {
$this->loadLayout();
$this->renderLayout();
}
}
由于您的控制器位于/Tbe/Report/controllers/Adminhtml/IndexController.php中,而不是/Tbe/Report/controllers/IndexController.php中,因此您需要使用<Tbe_Report after="Mage_Adminhtml">Tbe_Report_Adminhtml<...
尝试
<admin>
<routers>
<adminhtml>
<args>
<modules>
<Tbe_Report after="Mage_Adminhtml">Tbe_Report_Adminhtml</Tbe_Report>
</modules>
</args>
</adminhtml>
假设以下文件夹结构。
app/code/local/Tbe/Report/controllers/Adminhtml/ReportedController.php
菜单
<action>adminhtml/reported/index/</action>
使菜单链接如下所示:
<action>reported_products/adminhtml/index</action>
或更好的方法是,将您的管理路由器声明为另一个答案中所述的RS,在这种情况下,您需要将控制器从Tbe/Report/controllers/Adminhtml/IndexController.php
移至Tbe/Report/controllers/Adminhtml/Reported/IndexController.php
(也可以相应地更改类名),您可以使用如下菜单链接:
<action>adminhtml/reported/index</action>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.