0

When creating a theme I can override the Magento header by placing files under app/design/frontend/company/mytheme/Magento_Theme/layout/default.xml and app/design/frontend/company/mytheme/Magento_Theme/templates/header.phtml

This works as expected. But I want to move my custom header into a module as I'd like to use it on other themes.

If I place the same files under the module directory (instead of them) the header doesn't update:

app/design/frontend/company/module/Magento_Theme/layout/default.xml and app/design/frontend/company/module/Magento_Theme/templates/header.phtml

How can I make layout and template changes from within a module?

2 Answers 2

1

Please Try to below steps :-

1. How to Override Layout and templates files in theme

Layout :- /app/design/frontend/Company/Mytheme/Magento_Theme/layout/default.xml

templates :- /app/design/frontend/Company/Mytheme/Magento_Theme/templates/header.phtml

2. How to Override Layout and templates files in Module

Layout :- /app/code/Company/MyCustomModule/view/frontend/layout/default.xml

templates :- /app/code/Company/MyCustomModule/view/frontend/templates/header.phtml

After All Changes you need run below commands :-

php bin/magento s:up
php bin/magento s:s:d -f
php bin/magento c:c
php bin/magento c:f

THANKS.

0

Correct path is [Vendor]/[ModuleName]/view/frontend/layout and [Vendor]/[ModuleName]/view/frontend/templates

Your Answer

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

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