1

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

1

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.

  • i will try it please :) – HaFiz Umer Jun 27 at 7:05
0

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.

  • okay i will try it – HaFiz Umer Jun 27 at 7:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.