General developer forum

Course Format Topics Renderer override not working?

 
Picture of Ishani Vardhan
Re: Course Format Topics Renderer override not working?
 

Any suggestions at all?

 
Average of ratings: -
Gareth J Barnard
Re: Course Format Topics Renderer override not working?
 
Average of ratings: -
Picture of Ishani Vardhan
Re: Course Format Topics Renderer override not working?
 

Thanks Gareth, that's helpful! Will take a close look and see if there are more pointers I can borrow. In the meanwhile, I did manage to get something working. Please see my response below.

 
Average of ratings: -
Picture of Dave Emsley
Re: Course Format Topics Renderer override not working?
Particularly helpful Moodlers

Hi Ishani,

Just struggling with this myself but shouldn't your class begin with your theme name?  Mine is....

class theme_mytheme_course_renderer extends \core_course_renderer {
Or is that catered for within the "namespace"?


Hope this is useful. Dave
 
Average of ratings: -
Picture of Ishani Vardhan
Re: Course Format Topics Renderer override not working?
 

Thanks for your response Dave!

I have recently managed to make slight progress. Will post here, incase if that's helpful to anyone

My theme config file has this

$THEME->rendererfactory = 'theme_overridden_renderer_factory';
Then I'm extending lib/outputrenderers.php AND course/format/topics/renderer.php in the same file

theme > mytheme > classes > output > core_renderer.php

namespace theme_mytheme\output;

use coding_exception;
use html_writer;
use tabobject;
... n so on

defined('MOODLE_INTERNAL') || die;

/**
* Renderers to align Moodle's HTML with that expected by Bootstrap
*
* @package theme_mytheme
*/

class core_renderer extends \core_renderer { // Copy functions from core rendered but with my own custom code // For Ex public function header() { // my custom code }
} // In the same file at the end of this class, I'm extending another renderer require_once($CFG->dirroot.'/course/format/topics/renderer.php'); class format_topics_renderer extends \format_topics_renderer { // we can then modify topics_renderer OR format_renderer functions like this protected function section_activity_summary($section, $course, $mods) { // Parent code with own custom code } }

 
Average of ratings: Useful (1)
Gareth J Barnard
Re: Course Format Topics Renderer override not working?
Core developersParticularly helpful MoodlersPlugin developers

RE: "Then I'm extending lib/outputrenderers.php AND course/format/topics/renderer.php in the same file" = don't.

 
Average of ratings: -
Picture of Ishani Vardhan
Re: Course Format Topics Renderer override not working?
 

Why not? Is there a specific reason you wouldn't advocate this way of doing things?

It sure is the way some of the core files are built as well where you have multiple classes in your renderer. I have seen this way of extending in your theme in few forums, so doesn't seem like a non upgrade safe way of doing things & it works. 

 
Average of ratings: -