Je veux surcharger app/code/Magento/LayeredNavigation/view/frontend/templates/layer/view.phtml
dans app/code/NakedUi/LayeredNavigation/view/frontend/layer/view.phtml
. Source: How to Override a phtml File Using a Custom Module in Magento 2.
Créer un module NakedUi_LayeredNavigation qui contient au minimum les fichiers suivants:
./registration.php
1 2 3 4 5 |
<?php use Magento\Framework\Component\ComponentRegistrar; ComponentRegistrar::register(ComponentRegistrar::MODULE, 'NakedUi_LayeredNavigation', __DIR__); |
./etc/module.xml
1 2 3 4 5 6 7 8 |
<?xml version="1.0"?> <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd"> <module name="NakedUi_LayeredNavigation"> <sequence> <module name="Magento_LayeredNavigation" /> </sequence> </module> </config> |
Puis dans ./view/frontend/layout, créer les deux fichiers suivants:
catalog_category_view_type_layered.xml et catalogsearch_result_index.xml
1 2 3 4 5 6 7 8 9 10 |
<?xml version="1.0"?> <page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd"> <body> <referenceBlock name="catalog.leftnav"> <action method="setTemplate"> <argument name="template" xsi:type="string">NakedUi_LayeredNavigation::layer/view.phtml</argument> </action> </referenceBlock> </body> </page> |