Common layout for dynamic url in magento2

If two custom url must show a common layout template and need to show the data on the template file based on the `id` passed on.
ex:
domain/shop/index/order/id/1/
domain/shop/index/order/id/2/

Here shop is the route ID in the route file in the etc folder.
index :- Folder inside the controller.
order: The controller file.

Create a layout file based on this. So the layout file name will be a combination of all of the URL.
shop_index_order_id_{{id}}.xml

So on the template file get can access the variable by a code

$this->getRequest()->getParam(‘id’);

Thank you

Leave a comment

Your email address will not be published. Required fields are marked *