3

I am fairly new to Magento and I am currently working with version 2.1. I have created two new custom themes, I will call them Base and BaseChild for this example.

Locations
app/design/frontend/Base/default        //Inherits from Luma
app/design/frontend/BaseChild/default   //Inherites from Base

Inside the admin area, I have the base website set to use the BaseChild theme, and I have another site setup that is also using the BaseChild theme.

If I create a template file at BaseChild/default/Magento_Theme/templates/html/absolute_footer.phtml and add content to it, this will override the section on the page properly for the template. However, if I create a layout file at BaseChild/default/Magento_Theme/layout/default.xml and add the following content to it

<?xml version="1.0"?>
<!--
/**
 * Copyright © 2013-2017 Magento, Inc. All rights reserved.
 * See COPYING.txt for license details.
 */
-->
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
    <body>
        <referenceContainer name="footer-container" remove="true"/>
    </body>
</page>

This does nothing. But if I put this same file in the parent at Base/default/Magento_Theme/layout/default.xml it works and the footer is gone.

Why is my child theme not overriding properly even though the parent theme is.

1
  • Did you ever find a solution to this?
    – DiddleDot
    Commented Jun 10, 2021 at 20:43

3 Answers 3

2

I realize I'm years late to the question, but I struggled to find this answer for hours. Hopefully this will help someone else. This worked in Magento 2.4 on my child theme. Not sure if changing a child theme type will have any bad affects as updates come out.

Go to your database. select theme table. Check custom theme record. If the value of the type field is 1 change it to 0. This fixed my issue.

https://github.com/magento/magento2/issues/7710#issuecomment-306389802

After finding this answer I was able to find this question with an answer that gives a little more insight.

Magento 2 - Theme Type 0:physical, 1:virtual, 2:staging. When to use?

1
  • I was stuck and notice your post and it works for me, you are awesome DiddleDot. Commented Dec 5, 2021 at 3:34
0

You should place you override file into BaseChild/Magento_Theme/layout/override/theme/Magento/Base/default.xml

Ref: http://devdocs.magento.com/guides/v2.1/frontend-dev-guide/themes/theme-inherit.html#theme-inherit-layout-over

7
  • I tried this as well, which was not working. This would override the layout though, and I am trying to extend it in my example.
    – Metropolis
    Commented Jun 29, 2017 at 14:15
  • Though, getting either to work would be a start.
    – Metropolis
    Commented Jun 29, 2017 at 15:08
  • My reference contains info for extending layout
    – PY Yick
    Commented Jun 29, 2017 at 16:16
  • Yeah, thats the exact same tutorial I used to get to where I am. The problem is, it only deals with one theme deep inheritance.
    – Metropolis
    Commented Jun 29, 2017 at 17:22
  • Then it's strange. Did you set parent on theme.xml?
    – PY Yick
    Commented Jun 30, 2017 at 2:19
0

Try specifying a Vendor name and move your themes inside the Vendor folder. Your folder structure would look like this:

app/design/frontend/
├── <Vendor>/
│   │   ├──base/
│   │   │   ├── ...
│   │   │   ├── ...
│   │   ├──baseChild/
│   │   │   ├── ...
│   │   │   ├── ...

Then change the <parent> tag of your baseChild's theme.xml to

<parent>Vendor/base</parent>

And finally, move your theme files out of the default folder and put them directly under the theme folder, e.g. the path of your baseChild's layout file should now become:

app/design/frontend/Vendor/baseChild/Magento_Theme/layout/default.xml

Visit the official documentation page for further information.

1
  • Sorry I am already doing this. I just expected that it was implied to be in the correct spot, and I put the wrong directory structure. I am fixing that now. Vendor in your example would be Base/BaseChild in mine. And baseChild would be default. The base is inheriting correctly, and in the BaseChild I can override templates just fine so I know thats inheriting correctly. It is the layouts that are not.
    – Metropolis
    Commented Jun 29, 2017 at 14:17

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.