Inheritance in daughter themes

Inheritance in daughter themes

by Derek Chirnside -
Number of replies: 14

I've had a quick look through some of the docs, and couldn't find the answer to this question:

What is inherited from parent theme in a daughter theme?

Everything? Nothing? Just what you decide? or . . .?

-Derek

Average of ratings: -
In reply to Derek Chirnside

Re: Inheritance in daughter themes

by Just H -

I would have thought everything; idea of a child theme is to override certain elements/add to an existing theme isn't it?

In reply to Derek Chirnside

Re: Inheritance in daughter themes

by Gareth J Barnard -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Plugin developers

I believe you get everything from the parent unless you exclude it explicitly, like: https://github.com/gjb2048/moodle-theme_essential/blob/master/essentials/config.php#L33-L40.

In reply to Gareth J Barnard

Re: Inheritance in daughter themes

by Derek Chirnside -

Hello theme experts.

Thank you.

Just out of curiosity, what does https://tracker.moodle.org/browse/MDL-42961 mean?

A friend was looking at Decaf and we were thinking about child themes. He thought that not all inheritance was automatic if we went the daughter theme way.

-Derek

In reply to Derek Chirnside

Re: Inheritance in daughter themes

by Gareth J Barnard -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Plugin developers

I think that MDL-42961 needs backing up with more evidence to justify the breakages specified in the bullet points.

However, the last is true as I've demonstrated in the 'Essentials' child theme of 'Essential': https://github.com/gjb2048/moodle-theme_essential/blob/master/essentials/lib.php#L26-L39 - but I've not tried to see if changing this: https://github.com/gjb2048/moodle-theme_essential/blob/master/essentials/config.php#L64 to the 'Essential' one would work.

Plus, the second bullet point is false: https://github.com/gjb2048/moodle-theme_essential/blob/master/essentials/config.php#L44-L61.

And indeed the third: https://github.com/gjb2048/moodle-theme_essential/blob/master/essentials/renderers/core_renderer.php and https://github.com/gjb2048/moodle-theme_essential/blob/master/essentials/renderers.php.

In reply to Derek Chirnside

Re: Inheritance in daughter themes

by Mary Evans -
Picture of Core developers Picture of Documentation writers Picture of Peer reviewers Picture of Plugin developers Picture of Testers

The things inherited are all the parent's default settings, not the customisation.

As pointed out, the child theme is there to be not an identical copy, but as an individual with all the same features as the parent, but with the ability to change, otherwise it would just be a clone.

At the end of the day it depends what it is you want? A child (daughter) theme or a 'CLONE'.

Kind regards, 

Mary

In reply to Derek Chirnside

Re: Inheritance in daughter themes

by Danny Wahl -

that tracker item is talking about settings, which are not inherited by child themes, see MDL-27280 for a related issue

In reply to Danny Wahl

Re: Inheritance in daughter themes

by Derek Chirnside -

Danny, if this  MDL-27280  is still relevant, then what about updating the Fix Version?

-Derek

In reply to Derek Chirnside

Re: Inheritance in daughter themes

by Gareth J Barnard -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Plugin developers

The 'Essentials' child theme of 'Essential' already implements the dead easy to do workaround: https://github.com/gjb2048/moodle-theme_essential/blob/master/essentials/lib.php#L26-L39 as the parent function is in the global scope.  Yes, an array of functions for 'pre-processing' would be nice, but perhaps there should be a more object orientated approach as course formats have gone with 'format_base' in 'lib.php'.  In which case it would be a simple matter of the child theme method calling the parent method when it overrode it.  No need to check for function existence as 'duh' the parent class is already known about.

In reply to Derek Chirnside

Re: Inheritance in daughter themes

by Mary Evans -
Picture of Core developers Picture of Documentation writers Picture of Peer reviewers Picture of Plugin developers Picture of Testers

It looks like the parent only prettier...heart

In reply to Mary Evans

Re: Inheritance in daughter themes

by Just H -

Thanks for that Mary, after the day I had need a laugh ... and your post did the trick big grin

In reply to Just H

Re: Inheritance in daughter themes

by Mary Evans -
Picture of Core developers Picture of Documentation writers Picture of Peer reviewers Picture of Plugin developers Picture of Testers

You should try changing your avatar H...the one you have is a scream!

In reply to Mary Evans

Re: Inheritance in daughter themes

by Just H -

Almost sprayed the monitor with coffee just now cool