Hi Everyone,
I am using Moodle 3.7.2
I try to override a renderer from my base theme to a grand-child (course theme). The renderer contains around 40 methods so I would like to override only the 1 method I need in it. What happen is, for the methods
that are not overridden, Moodle gets them in the core renderer (/lib/outputrenderers.php) instead of my parent theme. How do I make Moodle understand that he has to use the renderer from my parent theme instead of Moodle’s core? Also, why an overridden
renderer in the parent theme does not affect the course theme (grandchild)?
Ideal situation:
I would override the renderer in my parent theme so the changes would be reflected in all the grandchild themes (8 courses in total, all have their
own course theme).
Good situation:
I override the renderer in each course theme but only the method I want to override. The rest of the method in the renderer are taken from the parent or base theme (not Moodle's core)
Moodle’s
core :
/lib/outputrenderers.php
Base theme: Name: RemUI \theme\remui\classes\output\core_renderer.php namespace theme_remui\output; class core_renderer extends remui_renderer { protected function render_context_header(\context_header $contextheader) { // This is the only method I want to override } }
Parent theme
config.php $THEME->name = 'MyParentTheme'; $THEME->parents = ['remui']; $THEME->rendererfactory = 'theme_overridden_renderer_factory';
\theme\MyParentTheme\classes\output\core_renderer.php namespace theme_remui\output; class core_renderer extends remui_renderer { protected function render_context_header(\context_header $contextheader) { // This is the method I want to override } }
Grand-child theme
config.php $THEME->name = 'MyGCTheme'; $THEME->parents = ['remui', 'MyParentTheme']; $THEME->rendererfactory = 'theme_overridden_renderer_factory';
\theme\MyGCTheme\classes\output\core_renderer.php namespace theme_remui\output; class core_renderer extends remui_renderer { protected function render_context_header(\context_header $contextheader) { // This is the method I want to override } }
I hope all this make sense. Please ask any question you may have.
Tank you in advance for your help