Magento 1.9:有没有一种方法可以在不重命名整个模块的情况下重命名路由?

问题描述 投票:1回答:1

我正在开发一个项目,其中一个名为Namespace_Ticket的模块适合作为发票列表。

但是,访问此模块的URL如下所示:

http://dev.local/index.php/tickets/index/index/ticket_id/9568/

我希望能够从URL中删除“ticket”一词,并将其替换为“invoice”。我希望我的网址如下所示:

http://dev.local/index.php/invoices/index/index/invoice_id/9568/

有没有办法我可以做到这一点,而无需重命名整个模块?

谢谢。

php magento magento-1.7 magento-1.9
1个回答
2
投票

路由器名称在模块的etc/config.xml文件中定义,您将找到类似于下面的代码

<routers>
    <modulename> <!--or this may be ticket -->
        <use>standard</use>
        <args>
           <module>Namespace_Ticket</module>
           <frontName>tickets</frontName> <!-- You have to change this value to change the router -->
        </args>
    </modulename>
</routers>

需要为admin和frontend单独定义路由器,你可以在<frontend><admin>节点下找到它们。

更改路由器前端名称后,请确保在整个站点中使用URL的任何位置都必须更改路由器。

© www.soinside.com 2019 - 2024. All rights reserved.