0

I am trying to set up a child theme of Luma but it's not appearing in the Admin area. I have checked I have it set up correctly, I think I have. Main area I'm worried about is that the original Luma files are in vendor/magento/theme-frontend-luma and I have set up the child theme in app/design/frontend. Does this make a difference? Should I be setting the child theme up in vendor also?

Files are as follows:

app/design/frontend/Mytheme/luma_child/theme.xml

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

app/design/frontend/Mytheme/luma_child/registration.php

<?php \Magento\Framework\Component\ComponentRegistrar::register(\Magento\Framework\Component\ComponentRegistrar::THEME, 'frontend/Mytheme/luma_child', __DIR__);

app/design/frontend/Mytheme/luma_child/composer.json

{
    "name": "Mytheme/theme-frontend-luma-child",
    "description": "N/A",
    "require": {
        "php": "~5.5.0|~5.6.0|~7.0.0|~7.1.0|~7.2.0|~7.3.0",
        "magento/luma": "100.0.*",
        "magento/framework": "100.0.*"
    },
    "type": "magento2-theme",
    "version": "100.0.1",
    "license": [
        "OSL-3.0",
        "AFL-3.0"
    ],
    "autoload": {
        "files": [
            "registration.php"
        ]
    }
}

Within Mytheme/luma_child I also have web folder with css, image, fonts and js folders, just copied from the vendor luma folder.

I have run composer update and magento setup:upgrade and a variety of other command line operations over the last few days since I set this up and it hasn't appeared.

What am I missing? Thanks!

1 Answers1

0

You have issue in your registration.php. You missed use It should be like:

<?php
use \Magento\Framework\Component\ComponentRegistrar;
ComponentRegistrar::register(ComponentRegistrar::THEME, 'frontend/Mytheme/luma_child', __DIR__);
Pawan
  • 5,856
  • 2
  • 14
  • 36
  • Thank you - I never spotted that. It also seems to be missing from various code I got from other sites, so not sure what happened there. However when I put that in the whole site is gone blank and anything I try to run in the command line doesn't seem to run – rodolphesalis May 13 '21 at 13:15
  • it seems it is due to missing media image.just remove <media> <preview_image>media/preview.png</preview_image> </media> from theme.xml and try again. – Pawan May 13 '21 at 13:20
  • I tried that - no joy, sorry!! Boss is wondering why I need to make child theme at all. Can I just use custom CSS to override Luma CSS? – rodolphesalis May 13 '21 at 13:31
  • The page that Rk Rathod linked to above doesn't have the use in the registration.php either – rodolphesalis May 13 '21 at 13:35
  • Ok - I have it, not sure what happened, but it's working now. I imagine it was something to do with the registration.php file, although I don't have use in it now either! Thank you for your help anyway!! – rodolphesalis May 13 '21 at 13:39
  • glad to know it is working for you. – Pawan May 13 '21 at 13:52