child theme - change renderer, inherit everything else

child theme - change renderer, inherit everything else

by tim st.clair -
Number of replies: 1
Picture of Plugin developers

I have moodle 3.8.2+ and moove theme.

I want a child theme to use as a way to overrider a renderer in a category and courses in that category, and leave everything else the same - e.g still apply the parent themes settings, custom scss, icons, logos, use the parent layouts, templates, etc. The child theme would not have its own stylesheet or settings.

(Incidentally, what is $THEME->hidefromselector property for? I imagined it would hide it from the theme selector only but it actually hides it from both the theme selector AND the drop-downs such as on the edit category page. I guess it must be for hiding parent themes?)

I know how to write the overridden renderer and have tested that part - that bit is fine. The child theme doesn't seem to be applying the parents colours, logo, or custom scss. What else is needed?

In config.php I have

defined('MOODLE_INTERNAL') || die();

require_once(__DIR__ . '/lib.php');

$THEME->name = 'moovechild';
$THEME->parents = ['moove','boost'];
$THEME->rendererfactory = 'theme_overridden_renderer_factory';
$THEME->sheets = [];
$THEME->editor_sheets = [];
$THEME->enable_dock = false;
$THEME->yuicssmodules = array();
$THEME->requiredblocks = '';
$THEME->addblockposition = BLOCK_ADDBLOCK_POSITION_FLATNAV;
$THEME->scss = function($theme) {
    $parentconfig = theme_config::load('moove');
    return theme_moove_get_main_scss_content($parentconfig);
};
$THEME->prescsscallback = 'theme_moovechild_get_pre_scss';
$THEME->extrascsscallback = 'theme_moovechild_get_extra_scss';
$THEME->iconsystem = '\theme_moove\util\icon_system';

In lib.php I have

defined('MOODLE_INTERNAL') || die();

function theme_moovechild_get_pre_scss($theme) {
    $theme = theme_config::load('moove');
    return theme_moove_get_pre_scss($theme);
}

function theme_moovechild_get_extra_scss($theme) {
    $theme = theme_config::load('moove');
    return theme_moove_get_extra_scss($theme);
}

Average of ratings: Useful (1)
In reply to tim st.clair

Re: child theme - change renderer, inherit everything else

by Gareth J Barnard -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Plugin developers
I can't see what you're doing wrong. Perhaps its an issue with the version of the Moove theme you're using in relation to the theme settings and how they are fetched - so not using the correct theme_config instance you're passing in with '$theme'.

$THEME->hidefromselector - Is there to hide a theme, such as a 'parent' when you want only a child theme to be selected. Thus in the past you could select 'Clean' but not 'Bootstrapbase' themes.