2

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.

| improve this question | | | | |
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

| improve this answer | | | | |
  • 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 Jun 29 '17 at 14:15
  • Though, getting either to work would be a start. – Metropolis Jun 29 '17 at 15:08
  • My reference contains info for extending layout – PY Yick Jun 29 '17 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 Jun 29 '17 at 17:22
  • Then it's strange. Did you set parent on theme.xml? – PY Yick Jun 30 '17 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.

| improve this answer | | | | |
  • 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 Jun 29 '17 at 14:17

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.