As we already know the use of routes.xml configuration file in Magento 2 but today we will learn about how it works.
Let’s take an example:
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:App/etc/routes.xsd">
<router id="standard">
<route id="custom_blog_manager" frontName="blog">
<module name="Webkul_BlogManager" />
</route>
</router>
</config>
Mostly we use the same value for id and frontName but what if we use different values like in the above example, first we need to know the working of these.
- id : it is used to create controller layout files, Magento identify the layout file which is store in view/[area]/layout/
Page Layout handlers are having name like
custom_blog_manager_blog_indxe.xml
custom_blog_manager_blog_view.xml
- frontName: it is used just after the base url, module’s controller url’s are identify by the frontName value.
Controller url’s are created like
blog/blog/index
blog/blog/view
blog/blog/save
Be the first to comment.