[RESOLVED] Do/should renderer overrides cascade through themes

[RESOLVED] Do/should renderer overrides cascade through themes

von Howard Miller -
Anzahl Antworten: 12
Nutzerbild von Core developers Nutzerbild von Documentation writers Nutzerbild von Particularly helpful Moodlers Nutzerbild von Peer reviewers Nutzerbild von Plugin developers

I am creating a theme that is based on the Bootstrap3 theme (i.e. that theme is its parent).

I wanted to modify the appearance of the breadcrumb trail so I overrode the core_renderer and wrote my own code for that function. It works fine. 

Unfortunately, a lot of other things are suddenly broken. It appears that Moodle is no longer 'seeing' the renderer overrides in the Bootstrap theme (well, I am assuming that). Is this to be expected? Do I need to copy the entire core_renderer code from the bootstrap3 theme into mine?

EDIT:
Just to try it - I did copy the whole class from bootstrap and it fixed the problems. So that does appear to be the case. Unless I am missing something of course. 

(Edited by Mary Evans - MARKED AS RESOLVED - original submission Thursday, 14 May 2015, 11:28 AM)

Als Antwort auf Howard Miller

Re: Do/should renderer overrides cascade through themes

von Gareth J Barnard -
Nutzerbild von Core developers Nutzerbild von Particularly helpful Moodlers Nutzerbild von Plugin developers

Hi Howard,

You only need to override what you want to change.  If you had to copy the whole class, then the inheritance chain is broken.  So its a 'daisy chain' being theme_yourtheme_core_renderer -> theme_bootstrap_core_renderer -> core_renderer.  See: https://github.com/gjb2048/moodle-theme_shoehorn/blob/MOODLE_27/renderers/core_renderer.php#L30 which chains with: https://github.com/bmbrands/theme_bootstrap/blob/master/renderers/core_renderer.php#L27.

Cheers,

Gareth

Als Antwort auf Gareth J Barnard

Re: Do/should renderer overrides cascade through themes

von Howard Miller -
Nutzerbild von Core developers Nutzerbild von Documentation writers Nutzerbild von Particularly helpful Moodlers Nutzerbild von Peer reviewers Nutzerbild von Plugin developers

Hmmm... that's what I was expecting. I wonder why it didn't work then...

Als Antwort auf Howard Miller

Re: Do/should renderer overrides cascade through themes

von Mary Evans -
Nutzerbild von Core developers Nutzerbild von Documentation writers Nutzerbild von Peer reviewers Nutzerbild von Plugin developers Nutzerbild von Testers

Have you put ...

$THEME->rendererfactory = 'theme_overridden_renderer_factory';

in your theme's config.php?

Als Antwort auf Mary Evans

Re: Do/should renderer overrides cascade through themes

von Howard Miller -
Nutzerbild von Core developers Nutzerbild von Documentation writers Nutzerbild von Particularly helpful Moodlers Nutzerbild von Peer reviewers Nutzerbild von Plugin developers

Yep... 

As I say... it worked, but the methods in the parent theme (bootstrap) where now not honoured and it reverted to the core_renderer methods. That is despite the parent being bootstrap my own renderer methods were honoured but the parent renderer methods appear to be ignored.

Als Antwort auf Howard Miller

Re: Do/should renderer overrides cascade through themes

von Mary Evans -
Nutzerbild von Core developers Nutzerbild von Documentation writers Nutzerbild von Peer reviewers Nutzerbild von Plugin developers Nutzerbild von Testers

Are you still calling the original bootstrap renderer into your core_renderer.php with this line...

include_once ($CFG->dirroot . '/theme/bootstrap/renderers/core_renderer.php');

For example:

https://github.com/gjb2048/moodle-theme_shoehorn/blob/MOODLE_27/renderers/core_renderer.php#L28

Als Antwort auf Mary Evans

Re: Do/should renderer overrides cascade through themes

von Howard Miller -
Nutzerbild von Core developers Nutzerbild von Documentation writers Nutzerbild von Particularly helpful Moodlers Nutzerbild von Peer reviewers Nutzerbild von Plugin developers

No... I have no includes at all. Should I have?

EDIT:
Ahhh.... should I be extending the parent (i.e. bootstrap) renderer class rather than core_renderer?

That's it isn't it? errötend

Als Antwort auf Howard Miller

Re: Do/should renderer overrides cascade through themes

von Mary Evans -
Nutzerbild von Core developers Nutzerbild von Documentation writers Nutzerbild von Peer reviewers Nutzerbild von Plugin developers Nutzerbild von Testers
Als Antwort auf Mary Evans

Re: Do/should renderer overrides cascade through themes

von Howard Miller -
Nutzerbild von Core developers Nutzerbild von Documentation writers Nutzerbild von Particularly helpful Moodlers Nutzerbild von Peer reviewers Nutzerbild von Plugin developers

I do my best, but even I can't be perfect all the time. It wouldn't be fair to others zwinkernd

Als Antwort auf Howard Miller

Re: Do/should renderer overrides cascade through themes

von Mary Evans -
Nutzerbild von Core developers Nutzerbild von Documentation writers Nutzerbild von Peer reviewers Nutzerbild von Plugin developers Nutzerbild von Testers

Put us out of our misery,  Howard, please tell us if it is working now?

Cheers

Mary