General developer forum

Issue extending core_renderer to override outputrenderers methods

 
Picture of Nathan Hunt
Issue extending core_renderer to override outputrenderers methods
 

There are a few Moodle renders I would like to override so that I can change the output/html for the custom theme I'm making.

There file is in the moodle root lib/outputrenderers.php

I did some searching around and came across https://docs.moodle.org/dev/Overriding_a_renderer#Our_first_renderer so I tried to follow this. I created a file in the root of my theme called renderers.php with the class:

class theme_mythemename_core_renderer extends core_renderer

And, for example on one of the methods I wanted to override, I copied the user_menu method and placed it within the class.

However, when I go to my moodle site I now get the error "Exception - Call to undefined method theme_mythemename_core_renderer::region_main_settings_menu()". The only method I have defined is the user_menu one, which is extending the core_renderer so I shouldn't imagine I have to copy every method over into my new class?

I must note I am using Moodle 3.3, and the docs in that link are a bit confusing as it states 2.9+ should use templates, but the methods I'm wanting to override are still using html_writer. So don't know if I'm going about it the right way or not?

I also have the following setting in my theme's config.php file:

$THEME->rendererfactory = 'theme_overridden_renderer_factory';

 
Average of ratings: -