Hello,
We choose Fordson theme for it's versatility but we have in mind functionnalities, involving many renderer and style changes.
So, in order to keep the base structure smoothly upgradable, we want to make a Fordson theme child.
At the moment we use Fordson 3.5 because our Moodle version is still 3.5 (we plan to upgrade later this year)
in our theme
in the config.php
require_once(__DIR__ . '/lib.php');
$THEME->name = 'epione';
// Inherit from parent theme - Fordson and grandparent Boost
$THEME->parents = ['boost','fordson']; //i also tried the reverse order
$THEME->sheets = [''];
$THEME->editor_sheets = [''];
// Call main theme scss - including the selected preset.
$THEME->scss = function($theme) {
return theme_epione_get_main_scss_content($theme);
};
// Call css/scss processing functions and renderers.
$THEME->csstreepostprocessor = 'theme_epione_css_tree_post_processor';
$THEME->prescsscallback = 'theme_epione_get_pre_scss';
$THEME->extrascsscallback = 'theme_epione_get_extra_scss';
// Most themes will use this rendererfactory as this is the one that allows the theme to override any other renderer.
$THEME->rendererfactory = 'theme_overridden_renderer_factory';
in scss folder, I have a
- epione_variables.scss with overrides
- styles.scss with some styles
preset/Epione.scss with our presets (our color scheme...)
in the lib/scss_lib.php i have in particular
function theme_epione_get_main_scss_content($theme) {
global $CFG;
$scss = '';
//1 - Load Fordson variables (for those i didn't override)
$scss .= file_get_contents($CFG->dirroot . '/theme/fordson/scss/fordson_variables.scss');
//2 - Load Epione preset
//same mechanism than Fordson, with our theme directory
//3 - Load Fordson style
$scss .= file_get_contents($CFG->dirroot . '/theme/fordson/scss/styles.scss');
//4 - Load Epione variables
$scss .= file_get_contents($CFG->dirroot . '/theme/epione/scss/epione_variables.scss');
//5- basic theme scss
$scss .= file_get_contents($CFG->dirroot . '/theme/epione/scss/styles.scss');
return $scss;
}
My other renderer modifications are taken into account: i've change the login page, some buttons from the navbar moved to a fixed side position... so no big problem there
The problem is that the styles are not loaded at all.
In non developper mode, i have a broken display, with not even the fordson styles, a kind of ugly Boost.
In developper mode, where i work mostly, i have no styles at all, except those from the core modules
When i look in the browser inspector, i have no css for styles_debug.php?theme=epione&type=scss
I have no php error in the logs.
But, I traced the compilation to lib/outputlib.php and the method protected function get_css_content_from_scss($themedesigner)
And i found 2 problems :
- when i dump the $paths variable, i have the array in this order :
- path to my theme
- path to boost
- path to fordson
- when i dump the $compiled, i have false meaning there's an error and it's catched in the exception : "Undefined variable $spacer: line: 81" (I think this is the first of many)
All of this seems to indicate there's a problem in the order of scss loading : my theme should be loaded last i think
Also, if i do a
$THEME->scss = function($theme) {
return 'body{background:red}';
};
I have a red background in non developper mode, but no style at all (and no style at all in developper mode. I don't know why)
I've seen this conversation in this forum but i see no help there
Is this a problem of grand child theme ? a problem of overriding fordson ? or am i missing somrthing obvious i didn't see in the docs ?
Thank you in advance for any help.