2

Dears,

I have a xml file in the vendor directory:

vendor/the_vendor/the_module/view/frontend/layout/the_file.xml

I know that I should never make any change in this directory as it may be overrided by composer. I also know that I should create the the_file.xml in my theme.

my theme path is:

app/design/frontend/the_Vendor/My_Theme/

Could you please let me know where the the_file.xml should be created (the exact path) in order to override the vendor xml file ?

2 Answers 2

1

Try this way...

vendor/the_vendor/the_module/view/frontend/layout/the_file.xml

to

app/design/frontend/Vendor/Themename/the_module/layout/the_file.xml

Please don't forget to clear cache after change in xml files

1
  • Upvoted question for marking answer as right for question. Commented Sep 6, 2020 at 14:44
1

Please look at magento 2 documentation

Reference:

https://devdocs.magento.com/guides/v2.4/frontend-dev-guide/layouts/layout-override.html

5
  • So I should always ignore the "view/frontend" ?
    – Anthony
    Commented Sep 4, 2020 at 16:31
  • At first you need to decide: are you gonna extend or override the layout. There are some differences in paths. And a big difference in functionality. But if you build your own theme, in most cases there is enough to extend layouts rather than override them. Yes you need to skip view/frontend after vendor/theme in app folder. You have already set the frontend path in the design folder Commented Sep 4, 2020 at 16:56
  • Unfortunately, it didn't work. I created the following path inside my theme: Module_Name/layout/The_file.xml the file in vendor contains the following: <move element="logo" destination="header-wrapper"/> So in the theme i wrote: <remove element="logo" destination="header-wrapper"/>
    – Anthony
    Commented Sep 4, 2020 at 18:51
  • As per your actions inside the_file.xml I assume that you need to extend the layout. U can use this link as a reference magento.stackexchange.com/questions/92196/… Commented Sep 5, 2020 at 6:38
  • And check please the way you removing the container For example In checkout_cart_index.xml: <?xml version="1.0"?> <page xmlns:xsi="w3.org/2001/XMLSchema-instance" layout="1column" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd"> <body> <referenceContainer name="header-wrapper" remove="true"/> </body> </page> That’s it. Commented Sep 5, 2020 at 6:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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