luma-theme .phtml file override in Custom Module
-
05-03-2021 - |
Domanda
i want to override this file magento_dir/vendor/magento/module-theme/view/frontend/templates/html/collapsible.phtml
And do not want to make custom theme like app\design\frontend\Magento_Theme\templates\html\collapsible.phtml
Can we override collapsible.phtml
in our custom_module
?
guide me i will be appreciate to answer
Soluzione
You can do so by overriding the template file in your custom module.
app/code/YourVendorName/YourModuleName/view/frontend/layout/customer_account_index.xml
Note : please replace you xml file name with customer_account_index.xml
and use referenceBlock name according your point of view sidebar.main.account_nav
or customer_account_navigation_block
<?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="customer_account_navigation_block">
<action method="setTemplate">
<argument name="template" xsi:type="string">YourVendorName_YourModuleName::collapsible.phtml</argument>
</action>
</referenceBlock>
</body>
</page>
I hope this can work for you.
Altri suggerimenti
Yes, actually you can do this. try this code in your xml of your module
app/code/vendor/module/view/frontend/layout/customer_account.xml
<?xml version="1.0"?>
<page layout="2columns-left" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
<body>
<referenceContainer name="sidebar.main">
<referenceBlock name="customer_account_navigation_block">
<action method="setTemplate">
<argument name="template" xsi:type="string">Vendor_Module::html/collapsible.phtml</argument>
</action>
</referenceBlock>
</referenceContainer>
</body>
</page>
This should work.