Why extending core theme always needs "base"

Why extending core theme always needs "base"

by out sider -
Number of replies: 4

I'm extending the core theme 'formal_white' and as such I've added the

$THEME->parents = array('formal_white');

to the config.php file under my theme folder. The issue is that if I don't also add the 'base' entry to the parents array the layout isn't displayed properly with some parts (like the left column) missing all together. 

What I don't get is why I need to include the 'base' if 'formal_white' theme already extends it and includes it on the parents config entry.

Any ideas?

(Edited by Mary Evans - original submission Wednesday, 9 January 2013, 11:25 AM) corrected typo in subject title: cheged 'basic' to 'base'.

Average of ratings: -
In reply to out sider

Re: Why extending core theme always needs "basic"

by Richard Oelmann -
Picture of Core developers Picture of Plugin developers Picture of Testers

Well, my assumption has always been that Moodle doesn't parse the entire parent theme(s) as a whole, but only the parts it needs, such as the css.

That would make it necessary to add each of the levels of parent themes in to your own theme, parents and 'grandparents' rather than just adding the parent theme itself.

I don't know if my reason is correct, but the effect, as you have found out, is that if you don't include base then there is no (or little) layout css to pick up for some regions.

Richard

In reply to out sider

Re: Why extending core theme always needs "basic"

by Brian Merritt -
Picture of Particularly helpful Moodlers

Hi o->s

I think the standard is 

$THEME->parents = array('standard', 'base');

It isn't hierarchical, all need to be added as parents here (I think)

 
In reply to out sider

Re: Why extending core theme always needs "basic"

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

Hi,

You only need to add the parent theme in the parent theme array if you want your theme to inherit the CSS from the parent themes. In yourcase it should be...

$THEME->parents = array('formal_white', 'base');

If, however, you don't want it to inherit the parent themes, then you must add all the styles to style it yourself from scratch.

Base theme is THE theme which styles all of Moodle core in order to make it work.

Standard theme is the DEFAULT theme which every NEW Moodle install starts off with, it inherits all the layout and CSS files from Base theme. In effect it is a prettier copy of base theme.

So if you want to make your theme an inherited theme of Formal White, you will need to add both formal_white and base themes to your parent theme array.

What you don't need to have in your inherited theme are the layout files or indeed the layout directory, neither do you need to list the $THEME->layouts in your inherited theme's config.php. See Standard theme for guidance with this.

What you can do then is just have one CSS file that allows you to change the theme in the areas you want it changing from the main Formal White theme.

These themes are great and easy to manage as the bulk of the code is in the parent theme from which your theme inherits. The only changes you need to make are in the settings and lib files, as these relate to your theme and not the parent theme. You can leave the renderer to use the parent theme, so no changes there. 

I hope this helps?

P.S: FW has some other files which I am not totally convined it actually needs these are the db and install files.  If you do keep these then you will need to change the instance of the old theme name for your theme name wherever you find it in those two directory files.

Mary




In reply to Mary Evans

Re: Why extending core theme always needs "basic"

by out sider -

Thanks alot or the very complete and compreensive explanation. Base has always to be inherited then...thanks