actiview/magento2-easy-routes
最新稳定版本:1.0.3
Composer 安装命令:
composer require actiview/magento2-easy-routes
包简介
Create multi-language custom routes with ease
README 文档
README
Create multi-language custom routes with ease, including layout handle for easy templating.
Installation
Install this package through Composer and then enable the module for Magento 2.
composer require actiview/magento2-easy-routes bin/magento module:enable Actiview_EasyRoutes
Usage
Adding a route involves a few easy steps, these steps are explained below. Have a look at the sample module: Actiview_EasyRoutesSample for the complete setup.
A new route is added to the routes pool through a etc/frontend/di.xml file. This file can be added in a custom module or one of you existing project modules.
Virtual Type
First create a virtualType:
<virtualType name="SamplePageEasyRoute" type="Actiview\EasyRoutes\Model\AbstractEasyRoute"> <arguments> <argument name="routeId" xsi:type="string">sample-page</argument> <argument name="storePaths" xsi:type="array"> <item name="" xsi:type="string">sample-page</item> </argument> </arguments> </virtualType>
To add multiple (multi-language) paths for the same ID use the next sample. The default route can be named default or the name can be empty. For the other paths use the relevant store code as name.
<virtualType name="SamplePageEasyRoute" type="Actiview\EasyRoutes\Model\AbstractEasyRoute"> <arguments> <argument name="routeId" xsi:type="string">sample-page</argument> <argument name="storePaths" xsi:type="array"> <item name="" xsi:type="string">sample-page</item> <item name="nl" xsi:type="string">voorbeeldpagina</item> <item name="de" xsi:type="string">beispielseite</item> <item name="fr" xsi:type="string">page-d-exemple</item> <item name="es" xsi:type="string">pagina-de-muestra</item> </argument> </arguments> </virtualType>
Paths
Now the new route is available for the router and the page can be visited:
- https://domain.tld/sample-page
- https://domain.tld/voorbeeldpagina
- https://domain.tld/page-d-exemple
- https://domain.tld/beispielseite
- https://domain.tld/pagina-de-muestra
When one of these pages is visited an additional layout handle will be added: easy_routes_sample-page. This can be used to apply additional or custom templating.
Usage (advanced)
You can provide your own CustomRoute object that implements EasyRouteInterface. Now you can provide your own logic, for exampling enableing/disabling a route for a store view.
Bugs / feature requests
Please use the GitHub Issue Tracker to report bugs or feature requests.
Versions
v.1.0.0
Initial release
统计信息
- 总下载量: 22
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 0
- 依赖项目数: 1
- 推荐数: 0
其他信息
- 授权协议: Unknown
- 更新时间: 2025-12-21