Pergunta

I have a theme installed using Magento 2 and I then have a child theme which I am using to make customisations.

Is it also possible to then create a child them of that child which I can use to make a custom header design which will take everything else from the child theme.

I essentially only need to replace the header logo on some pages like the home page and a child > child theme seems like an easy solution but not sure how to make it work.

Foi útil?

Solução

Yes, You can create child theme of child theme. You have to defined old child as parent in new child theme

new child theme.xml

<theme xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Config/etc/theme.xsd">
    <title>New Child Theme</title>
    <parent>OldChildtheme/customthem</parent>
    <media>
        <preview_image>media/preview.png</preview_image>
    </media>
</theme>

Outras dicas

I think you just need to create a child theme inside your current child theme and specify your current child theme as the parent of your new child-child-theme. That will do the trick.

So your child-child theme theme.xml should look like:

<theme xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Config/etc/theme.xsd">
    <title>Child Child Theme</title> 
    <parent>Currentchild/themename</parent> 
    <media>
        <preview_image>media/preview.jpg</preview_image> 
    </media>
</theme>

Magento uses infinite callback mechanism for the themes. That means you can have infinite number of children under a theme and Magento will pick the right file from the parent if it didn't find one from the relevant child.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a magento.stackexchange
scroll top