Parent theme issues in 2.0

Parent theme issues in 2.0

by Patrick Malley -
Number of replies: 7
I'm having some trouble with 2.0 theme parents and could use some prompt help to keep me working on this new theme "families" idea.

  1. My most recent commit includes two new themes:
    • Canvas - this is going to be my new family theme.
      1. Is it possible to hide this family theme as Base is hidden? Is there a setting I can add to config.php to do this?
    • Form Factor - This is a 2.0 version of my 1.9 theme called Ingenuous. It might be a bit broken now because I'm trying to build it upon Canvas, which is built upon Base.
  2. If I use Canvas as a parent, does base need to be specified explicitly as a parent too? It shouldn't since canvas has it listed as a parent. But it doesn't seem to be working properly this way.
  3. I'm having a lot of issues with stylesheets not being included from parent themes. Here's what I did:
    • Canvas excludes the Base pagelayout.css file and includes its own. I have it excluding properly, but it doesn't include the new pagelayout file from Canvas.


I think I'll leave it here for now to prevent a million questions in one single post. This should get me on track.
Average of ratings: -
In reply to Patrick Malley

Re: Parent theme issues in 2.0

by Patrick Malley -
I've answered my own number 2 and 3:

2.) You have to include all themes from which you want to use and then exclude the stylesheets from the parents you don't want to use by using:

$THEME->parents_exclude_sheets

Overriding the layouts in the parent themes is as easy as setting them in your own config.php.

3.) There must have been a syntax error in my pagelayout.css file because I now have it working without change to config.php.

As a side note:

If you want to build a theme on top of a theme and the base theme, be sure to set the base theme second in the array:

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

For some reason, the default method for loading the stylesheets is from right to left. If you place base first, then the stylesheets from base will load lower in the cascade and will override your other parent theme.
In reply to Patrick Malley

Re: Parent theme issues in 2.0

by Sam Hemelryk -
Hi Patrick

In regards to the 1.1 Is it possible to hide the family theme as base is hidden... No currently there isn't.

I've just filled MDL-22223 and will sort out a solution for it this morning.

Cheers
Sam
In reply to Patrick Malley

Re: Parent theme issues in 2.0

by Sam Hemelryk -
There is now a setting to hide a theme from the theme selector (unless theme designer mode is on).
Add the following to your theme's config.php file:

$THEME->hidefromselector = true;
Average of ratings: Useful (1)
In reply to Sam Hemelryk

Re: Parent theme issues in 2.0

by Tim Hunt -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
Nice.

... but I am just wondering if this is the best name. It is both quite long, and quite vague. But I can't come up with a clearly better suggestion. (As a developer, my first thought was $THEME->abstract = true; like abstract class in PHP wink)

Also, hiding from the theme selector is just an outcome we want. The real thing about the theme is that it is not a real, finished theme, but only something intended to be used as the parent of other themes.

Some possibilities:

$theme->basetheme = true;
$theme->complete = true;
$theme->enabled = false;
$theme->finished = true;
$theme->parentonly = true;
$theme->selectable = true;
$theme->usable = true;

Of those, I think basetheme or parentonly are probably the clearest.
In reply to Tim Hunt

Re: Parent theme issues in 2.0

by Patrick Malley -
I think $theme->basetheme = true; is confusing as it suggests there is more than one base when there isn't since we named one theme specifically as "base."

These three all seem to suggest that something is wrong if this setting is not included:

$theme->complete = true;
$theme->finished = true;
$theme->usable = true;

Of course, we want all themes in the core to be complete, finished, and usable in some way. I know what you're getting at here, but it's not as clear to the new theme developer.

These two (and Sam's original idea) make the most sense to me:

$theme->parentonly = true;
$theme->selectable = false;

Note that I've changed the boolean value in the second option so it would default to true.
In reply to Patrick Malley

Re: Parent theme issues in 2.0

by Jon Witts -
Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Testers
For me, parentonly is probably the clearest...