我在Magento adminpanel中的模块具有与http://example.com/index.php/mymodule/一样的URL,并包含带有订单的自定义网格.我想在用户点击网格行时将用户重定向到标准的"订单视图"页面.
public function getRowUrl($row)
{
if (Mage::getSingleton('admin/session')->isAllowed('sales/order/actions/view')) {
return $this->getUrl('sales_order/view', array('order_id' => $row->getId()));
}
return false;
}
Run Code Online (Sandbox Code Playgroud)
但是这个URL指向http://example.com/index.php/sales_order/view/ ...而不是http://example.com/index.php/ admin/sales_order/view/...有什么建议吗?
UPD.config.xml:
<admin>
<routers>
<mymodule>
<use>admin</use>
<args>
<module>Foo_Mymodule</module>
<frontName>mymodule</frontName>
</args>
</mymodule>
</routers>
</admin>
Run Code Online (Sandbox Code Playgroud)
很简单,你需要更换sales_order/view有*/sales_order/view.该*方法使用管理员中的当前路由器adminhtml.
编辑
要更详细地解释,请将其放入配置中,
<admin>
<routers>
<adminhtml>
<args>
<modules>
<mymodule after="Mage_Adminhtml">Foo_Mymodule_Adminhtml</mymodule>
</modules>
</args>
</adminhtml>
</routers>
</admin>
Run Code Online (Sandbox Code Playgroud)
现在该值*/mymodule/index将生成一个URL http://example.com/index.php/admin/mymodule/index,该URL 又将加载文件Foo/Mymodule/controllers/Adminhtml/MymoduleController.php并尝试查找该方法Foo_Mymodule_Adminhtml_MymoduleController::indexAction().如果该方法存在则运行,否则管理路由器接管并显示404或重定向到仪表板.
| 归档时间: |
|
| 查看次数: |
11837 次 |
| 最近记录: |