
- For example : we override template file of checkout/cart/index controller page.
- Create checkout_cart_index.xml in app/code/[Name_Space]/[Your_Module]/view/frontend/ layout
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
<?xml version="1.0"?> <page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance dc" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd"> <referenceBlock name="checkout.cart"> <action method="setTemplate"> <argument name="template" xsi:type="string">[Name_Space]_[Your_Module]::checkout_cart.phtml</argument> </action> </referenceBlock> </page> |
- checkout.cart : is block name, whose template file you want to override.
- [Name_Space]_[Your_Module]::checkout_cart.phtml : is a template file of your module.
- Create checkout_cart.phtml file in app/code/[Name_Space]/[Your_Module]/view/frontend/templates
The steps I mention above is the shortest process for you to Override a Template File in Magento 2. With this guide, you can manage the Template File in Magento 2 easily. Every store has a Template File in Magento 2 with many attributes.
Thank you for reading this post and see you in other posts from Magestore!