2

I'm relatively new to this, so i hope someone can help me out.

In my store i have a child theme of blank. The changes in this child theme get properly displayed on the store front and everything not changed is inherited from blank (as it should be).

Now i need another child theme of this child theme to make some additional changes for specific sites in _theme.less. So i tried to create a child theme that inherits from my first child theme that inherits from blank. But the result is that it does not inherit the changes i made in _theme.less in the first child theme. New changes in _theme.less work but everything else is inherited from blank instead of the child theme of blank.

If i delete _theme.less in the child-child-theme it displays everything as changed in the first child theme. So i think the problem is that the new _theme.less overrides the _theme.less from it's parent completely. Shouldn't the child-child theme inherit everything from the child theme's _theme.less except when it is changed in it's own _theme.less?

Would be great if someone could show me a way out of this problem.

1 Answer 1

1

Because you have a CSS file with the same name in your childchild theme it TOTALLY overwrites and replaces the CSS in the child theme. Therefore change the name of the CSS file in the childchild theme and both will load.

EDIT you will also need to reference the new file name in your childchild theme in the _extend.less file with

@import 'myname.less';

More info here as well less files - magento.stackexchange

2
  • Thank you! So it is a different behavior for the child theme than for the child-child theme. I find that a little strange. Now that i understood how it works, i used a similar solution. I used @import 'myname.less'; in the child theme's _theme.less and also created a blank 'myname.less' for the child theme. In the child-child theme i made all the necessary changes in the 'myname.less'. This way the changes are treated as part of _theme.less and not _extend.less.
    – Miss Oats
    Jun 4, 2019 at 11:55
  • That is one way to do it. It is all a cascade effect starting at the top theme (child-child in your case) for priority. So it will start building from the Magento blank theme and work its way up. So now it will load myname.less from your child theme, then find the file with the same name in your child-child theme and over write the one it found in your child theme. The same applies to any files you put into your child-child theme and it is how you can over write .HTML/.XML/.PHP/.PHTML code etc in Magento2 without editing the core files. Glad that you got it working!
    – Anthony
    Jun 5, 2019 at 1:49

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.