Bootstrap Parent / Child Theme Override?

Bootstrap Parent / Child Theme Override?

Brian Merritt -
回帖数:12

Hi all

Moodle 2.5 question

I have cloned the 'clean' theme and that is working fine.  However, I want to change the front page to 'pre-side' only and remove the right hand column.

If I copy $THEME->layouts = array( etc etc ) to my new Theme, making changes to the layout has no effect.  

If I delete     , 'side-post'     on the config.php in bootstrapbase theme, the desired change takes place.

Shouldn't the child theme be able to override the parent?  Am I doing it wrong??

 

Thanks all


Brian

回复Brian Merritt

Re: Bootstrap Parent / Child Theme Override?

Brian Merritt -

PS - I am also changing the "general.php" layout in the new child theme, and the changes are not being seen.  The theme appears to revert to parent bootstrapbase general.php for layout.

回复Brian Merritt

Re: Bootstrap Parent / Child Theme Override?

David Scotson -
It's not something I know offhand but what I'd do would be to look at another theme that makes this change and see how they override it. The Clean theme should work just the same.

The other thing to check is purging all caches, because some parts of themes get cached much stronger than others.
回复Brian Merritt

Re: Bootstrap Parent / Child Theme Override?

Gareth J Barnard -
Core developers的头像 Particularly helpful Moodlers的头像 Plugin developers的头像

Dear Brian,

Can I suggest that possibly taking a copy of the bootstrap base 'general.php' file calling it something different, say 'frontpage.php', place it in your layout folder, making your changes, editing your 'config.php' file to refer to it and leave the rest to be inherited from 'bootstrapbase' would work.

Cheers,

Gareth

回复Gareth J Barnard

Re: Bootstrap Parent / Child Theme Override?

Brian Merritt -

Thanks Gareth - That works for the page layout, but doesn't help with my config.php settings for $THEME->layouts ( I still have to modify bootstrapbase to achieve a different page layout).

Is the above true for other theme types?  I remember being able to redo a theme, and the config.php and general.php of the child would always override the parent theme.

Not sure if this is a bootstrap issue, a 2.5 issue, or my brainpower and memory failing 微笑

回复Brian Merritt

Re: Bootstrap Parent / Child Theme Override?

Mary Evans -

Hi Brian,

The Clean theme has it's own general.php in it's layout directory. Make a copy of THAT general.php NOT bootstrapbase, as the two are very different. Then rename the copy general.php to frontpage.php or as I tend to do and call it home.php. In actual fact in my cloned themes I call general.php, default.php, but that's my preference for file naming.

Next thing to do is copy ALL the $THEME->layouts from theme/bootstrapbase/config.php to theme/clean/config.php and change the front page layout so it only uses the side block of your choice, like so...

    // The site home page.
    'frontpage' => array(
        'file' => 'frontpage.php',
        'regions' => array('side-pre'),
        'defaultregion' => 'side-pre',
        'options' => array('nonavbar'=>true),
    ),

Before doing anything else do a Purge all caches. Otherwise you may end up with a code error because Moodle will be looking for the side column that isn't there.

Hope that helps?

Mary

回复Brian Merritt

Re: Bootstrap Parent / Child Theme Override?

Gareth J Barnard -
Core developers的头像 Particularly helpful Moodlers的头像 Plugin developers的头像

Dear Brian,

No worries.  I think the solution is generic and does not apply to just Bootstrap.  I always thought that child layouts overrode the parent layout - Mary what do you think?

Looking at http://docs.moodle.org/dev/Category:Themes and http://docs.moodle.org/dev/Creating_a_theme there does not seem to be anything like 'parentexcludelayout'.

Cheers,

Gareth

回复Gareth J Barnard

Re: Bootstrap Parent / Child Theme Override?

Mary Evans -

@Gareth:

My thought on this situation Gareth, is that I think Brian is doing something wrong.

@Brian: It may be worth your while to enable 'Debugging'. (Administration/Development/Debugging) and also enable Theme Designer Mode if not already on.

Also try not to do too many things at once.  Might even be a good idea to refresh your server if working on a Localhost server.  Or just turn off your computer and make a cup of tea! 微笑

Cheers

Mary

回复Gareth J Barnard

Re: Bootstrap Parent / Child Theme Override?

Richard Oelmann -
Core developers的头像 Plugin developers的头像 Testers的头像

Hi Gareth,

Child layouts do override the parent layouts where they are declared as can be seen with Clean overriding the Bootstrapbase general.php with its own (not declared in the config.php because the file name and the layout options are the same as those declared in bootstrapbase, but a theme looks in its own layout folder first before looking to the parent for that layout file unless specifically directed to the parent).

There shouldn't be any need for a parentexcludelayout as this is implicit in the theme declaring its own layouts and excluding parent layout files would run the risk of an error in a theme preventing the layouts falling back to the ultimate parent theme - base/bootstrapbase.

Brian: Beyond Mary's comments above, the one other thing that comes to mind is to check the permissions on the files - particularly on your replacement layout file - if Moodle/the webserver user can't see it then it will go looking to the parent theme layouts.

R

回复Richard Oelmann

Re: Bootstrap Parent / Child Theme Override?

Gareth J Barnard -
Core developers的头像 Particularly helpful Moodlers的头像 Plugin developers的头像

Ok, +1 for making a cup of tea - always helps 微笑

A 'purge all caches' probably won't work as they are php files served up by the server and as such are not cached by Moodle.  However, I do know that certain LAMP / WAMP etc. framework stacks like Zend Server do cache and optimise php files, so something going on there?  Perhaps restart 'apache'.

Could it also be that you are editing the files in one installation but your web browser is using another?  I've often kicked myself over this as have nine installations of Moodle on my machine and was just using the wrong one and wondered why my changes were not showing up.

Cheers,

Gareth

回复Gareth J Barnard

Re: Bootstrap Parent / Child Theme Override?

Brian Merritt -

Thanks all - very glad I didn't have a glass of wine at lunch time!

I will review all the above and come back regardless - I really appreciate everyone's fast support!

I did have theme mode and debug on, with no errors thrown, but will have another go as the work I have done on 2.4 will transfer across (thanks to LESS)

回复Brian Merritt

Re: Bootstrap Parent / Child Theme Override?

Brian Merritt -

Gareth wins the prize for spotting my most annoying error - editing the theme to change all the names, copying that to the development server, and then finding that despite any changes nothing happened because I was still editing the origninal location!

Please don't delete this thread - use it as a warning to others 微笑

回复Brian Merritt

Re: Bootstrap Parent / Child Theme Override?

Mary Evans -

I knew you must have been doing something wrong!

You probably need that cuppa now!

cjeers