Theme dependancies / inheritance

Theme dependancies / inheritance

by Chris Clark -
Number of replies: 3

Hey Moodle theme devs!

I'm working with Moodle 2.9.1 primarily, but possibly also Moodle 2.7.x.

I'm starting a new theme project that may end up being the base for multiple client themes.

In the past I've just cloned my base theme and made any modifications as necessary, this doesn't seem like an optimal way to maintain the base theme and be able to push updates to the base while leaving any client overrides intact.

This is where I believe Moodles dependencies come into play.

If I understand these correctly any plugin can have a dependency on another defined in the config like so:

$plugin->dependencies = array(

'theme_bootstrapbase'  => 2015050500,

    'theme_clean'  => 2015051100,

On its own all this does is check whether the following plugins are installed and have a minimum version.

Then within our theme we can declare the parent themes like so:

$THEME->parents = array('bootstrapbase', 'clean');
How does this parents list work?

For example the first parent has it's config file load, following by the second parent and then finally the current themes configuration, with any re-declarations overriding the previous?


I'm interested in whether my understanding of this is correct and how extensive the inheritance is?

If my new theme does not declare a layout for the frontpage, but the second parent does than will that layout be used?

I've seen a command to exclude specific css sheets from any given parent so I assume all css used by the parent is inherited by default and any rules that conflict will be resolved by load order.

Are settings inherited from parent to child themes?

Are resources from a parent theme usable by children themes? i.e the pix folder

If anyone has an understanding of theme dependencies / inheritance or an example of how to set one up I would be very interested to have a chat regarding it.

My plan as I see it is to either modify the clean / more theme provided in moodle core OR have a new theme dependent on one of them that will act as my base, then whenever I need a client specific theme I will simply say that it is dependent on my new base.

This would allow my base to accept updates from clean / more and my client themes to accept updates to my base as I improve it moving forward.

Average of ratings: -
In reply to Chris Clark

Re: Theme dependancies / inheritance

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

No...parent list in config.php is other way round...as in (parent, grand-parent)

$THEME->parents = array('clean', 'bootstrapbase');

Sorry but am dashing off...

Catch you later!

Mary

In reply to Chris Clark

Re: Theme dependancies / inheritance

by Chris Clark -

Thanks Mary, one part clarified, it's a start!

Another issue I was considering, If a theme has a parent theme and that theme also has a parent theme does the new child theme need to know about the parents parents and declare them in its own list of parents or is that handled by the system where the parent knows its own parents already?

In reply to Chris Clark

Re: Theme dependancies / inheritance

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

Just editing this to say that assuming you are using the Clean theme to make a child theme. Which is basically only a vehicle for carrying custom settings, renderers and stylesheets, it will need parents listing like so...

$THEME->parents = array('clean', 'bootstrapbase');

If you then make the child theme into a parent then you would need to list parents like so...

$THEME->parents = array('clean_child',  'clean', 'bootstrapbase');

Hope this helps?

Mary

Edited: