[RESOLVED] Do/should renderer overrides cascade through themes

[RESOLVED] Do/should renderer overrides cascade through themes

написао/ла Howard Miller -
Број одговора: 12
Слика Core developers Слика Documentation writers Слика Particularly helpful Moodlers Слика Peer reviewers Слика 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)

У одговору на Howard Miller

Re: Do/should renderer overrides cascade through themes

написао/ла Gareth J Barnard -
Слика Core developers Слика Particularly helpful Moodlers Слика 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

У одговору на Gareth J Barnard

Re: Do/should renderer overrides cascade through themes

написао/ла Howard Miller -
Слика Core developers Слика Documentation writers Слика Particularly helpful Moodlers Слика Peer reviewers Слика Plugin developers

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

У одговору на Howard Miller

Re: Do/should renderer overrides cascade through themes

написао/ла Mary Evans -
Слика Core developers Слика Documentation writers Слика Peer reviewers Слика Plugin developers Слика Testers

Have you put ...

$THEME->rendererfactory = 'theme_overridden_renderer_factory';

in your theme's config.php?

У одговору на Mary Evans

Re: Do/should renderer overrides cascade through themes

написао/ла Howard Miller -
Слика Core developers Слика Documentation writers Слика Particularly helpful Moodlers Слика Peer reviewers Слика 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.

У одговору на Howard Miller

Re: Do/should renderer overrides cascade through themes

написао/ла Mary Evans -
Слика Core developers Слика Documentation writers Слика Peer reviewers Слика Plugin developers Слика 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

У одговору на Mary Evans

Re: Do/should renderer overrides cascade through themes

написао/ла Howard Miller -
Слика Core developers Слика Documentation writers Слика Particularly helpful Moodlers Слика Peer reviewers Слика 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? стиди се

У одговору на Howard Miller

Re: Do/should renderer overrides cascade through themes

написао/ла Mary Evans -
Слика Core developers Слика Documentation writers Слика Peer reviewers Слика Plugin developers Слика Testers
У одговору на Mary Evans

Re: Do/should renderer overrides cascade through themes

написао/ла Howard Miller -
Слика Core developers Слика Documentation writers Слика Particularly helpful Moodlers Слика Peer reviewers Слика Plugin developers

I do my best, but even I can't be perfect all the time. It wouldn't be fair to others намигује

У одговору на Howard Miller

Re: Do/should renderer overrides cascade through themes

написао/ла Mary Evans -
Слика Core developers Слика Documentation writers Слика Peer reviewers Слика Plugin developers Слика Testers

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

Cheers

Mary

У одговору на Mary Evans

Re: Do/should renderer overrides cascade through themes

написао/ла Howard Miller -
Слика Core developers Слика Documentation writers Слика Particularly helpful Moodlers Слика Peer reviewers Слика Plugin developers

Yep - it works perfectly. Thanks.

Like all the best bugs - completely obvious once you know what the answer is!