Suppose that I want to edit the file
vendor/magento/module-theme/view/frontend/layout/default.xml
Do I edit the file directly?
It seems not a best practice to me.
Or is there anyway I can extend the file to override the content.
Suppose that I want to edit the file
vendor/magento/module-theme/view/frontend/layout/default.xml
Do I edit the file directly?
It seems not a best practice to me.
Or is there anyway I can extend the file to override the content.
You can use the following to override the layout file. For Example,
vendor/magento/module-theme/view/frontend/layout/default.xml
<vendor_theme_dir>
|__/<vendor_theme>
|__/Magento_Theme
|__/view
|__/frontend
|__/layout
|__/default.xml
So you just need to override a file under your theme folder.
app/design/frontend/Magento
and there is no additional folder or file inside it. So i add Luma/Magento_Theme/view/frontend/layout/default.xml
inside it am i right?
Commented
Jan 8, 2018 at 6:29
You can do the following things. Create new theme and override this layout in theme. Check luma theme, how to override any xml. And do the same. Check official documentation
To add an overriding theme file (to override a parent theme layout):
<theme_dir>
|__/<Namespace_Module>
|__/layout
|__/override
|__/theme
|__/<Parent_Vendor>
|__/<parent_theme>
|--<layout1>.xml
|--<layout2>.xml
Reference: http://devdocs.magento.com/guides/v2.2/frontend-dev-guide/layouts/layout-override.html
Firstly you must create a local theme, for do that you have to create the blow structure
app
---->desing
-------->frontend
------------>Vendor
---------------->default
In this folder you create 2 files
registration.php
<?php
\Magento\Framework\Component\ComponentRegistrar::register(
\Magento\Framework\Component\ComponentRegistrar::THEME,
'frontend/Vendor/default',
__DIR__
);
theme.xml
<theme xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Config/etc/theme.xsd">
<title>Vendor Theme</title>
</theme>
And finaly you have to create a below structure
Magento_Theme
---->layout
-------->default.xml