2011-09-05 118 views
5

我在Magento adminpanel中的模块具有类似于http://example.com/index.php/mymodule/的URL,并包含具有订单的自定义网格。当他点击网格行时,我想将用户重定向到标准的“订购视图”页面。如何使用Magento中的getUrl()引用另一个模块?

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; 
} 

但这个URL指向http://example.com/index.php/sales_order/view/ ......而不是http://example.com/index.php/管理的/sales_order的/图/ ...任何建议?

UPD。 config.xml中

<admin> 
    <routers> 
     <mymodule> 
      <use>admin</use> 
      <args> 
       <module>Foo_Mymodule</module> 
       <frontName>mymodule</frontName> 
      </args> 
     </mymodule> 
    </routers> 
</admin> 
+1

看看正确的配置[如何获取Magento管理员页面/部分的URL](http://stackoverflow.com/questions/6877683/how-to-get-the-url-of -a-page-section-in-magento-admin/6881211#6881211) – clockworkgeek

+0

@clockworkgeek谢谢。请看看我更新的帖子。它看起来与config.xml的情况相似,不是吗? – silex

+0

您的'frontName'是'mymodule',但如果您更仔细地复制示例,则可以使用'admin'代替。 – clockworkgeek

回答

7

很简单,你需要*/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> 

现在价值*/mymodule/index将生成一个URL http://example.com/index.php/admin/mymodule/index这反过来将加载该文件Foo/Mymodule/controllers/Adminhtml/MymoduleController.php并试图找到方法Foo_Mymodule_Adminhtml_MymoduleController::indexAction()。如果方法存在,则运行该方法,否则管理路由器将接管并显示404或重定向到仪表板。

+0

用'*/sales_order/view'指向'http:// example.com/index.php/mymodule/sales_order/view /'。我也很惊讶。 – silex

+1

感谢您的评论,我已经完全重写了布局配置中的路由和路径,所以现在''/ sales_order/view'现在一切正常。 – silex

+0

你是如何改写的?我也有完全一样的问题!使用**/sales_order/view *还会将我重定向到* index.php/mymodule/sales_order/view/*,而不是* index.php/admin/sales_order/view/*。谢谢你的帮助! – EOB

相关问题