I'm investigating in Moodle 2.0 theming and am pleased with the possibilities. Many of my old dreams how to work on Moodle Themes seam to have come true.
But where there is light there is also shadow:
I'm investigating in Moodle 2.0 theming and am pleased with the possibilities. Many of my old dreams how to work on Moodle Themes seam to have come true.
But where there is light there is also shadow:
Moodle 2.0 themes are a whole new world. When I started to investigate more in Moodle 2.0 I felt close to having never worked with Moodle before.
The all different theme structure, files and CSS demand intensive exploration. Looking at existing themes, mainly the base and canvas theme, becomes important.
To be able to understand the applied CSS rules is an important base to be able to write well functioning CSS in my themes. To be able to understand CSS rules I need to be able to read the existing CSS. The one line CSS rules in base and canvas are horrible to read. It takes time to convert them to a readable format - and that work needs to be done after each theme update.
Sam opened the tracker issue MDL-22351 - but nothing happened. In an old posting Sam writes that time is lacking. To take the CSS trough one of the several CSS beautifiers takes an hour or so. If this work would be done once for Moodle core Moodle CSS would become so much easier to understand out of the box.
The chance that well working CSS without unnecessary overwrites will be written will increase with good readable Moodle base CSS. So please someone convert the CSS to a readable format.
I agree. Please see: MDL-25511
Good documentation makes the work easier for theme developers/designers. Good documentation is also essential for theme quality.
By the way Sam, the documentation you have written in the Moodle docs wiki is really good. Thanks for that huge help to understand Moodle 2 themeing.
Having easily readable CSS is part of a good documentation. So please change the one liners to a human readable format.
Smashing Magazine published an interesting article how formatting supports understanding. "The Poetics Of Coding"
Moodle CSS lays a font fundament with the well thought YUI CSS reset and YUI CSS fonts rules. YUI has investigated some effort to make text look more similar on the different browsers. When you have a look at YUI 3: CSS Fonts you may see what I mean. These font rules are set on the body tag.
When in any theme font related definitions are assigned to the body tag the base system breaks - as done in "text.css" in canvas for example. Many advantages using the YUI CSS font rules are thrown away.
To keep the advantages add font related rules to a subsequent element like "div#page" in all themes. On the above mentioned web page YUI publishes a table on font size values you can use to set certain text sizes - working the same in many different browsers out of the box.
By removing the font-size from the body tag and setting the font size in text.css in the canvas theme to "font-size: 108%" for "#page" I verified that the expected 14px font size in the themes are set.
So please keep the font handling advantage given with the YUI CSS system and add your rules to a subsequent element. Patrick, would you mind to correct the CSS rule in canvas?
Urs,
Yes I agree, typography is very important in design and any CSS strategy that enables theme designers to achieve consistent cross-browser type display gets my vote.
~thomas
Sorry it took an additional prod to get me to respond. Been quite busy with 2.0 upgrades lately. I have looked at the YUI 3 CSS font guidelines and have added MDL-25512 to make the change.
To get well structured theme directories with the advantage to easily know where to look for certain files is wise to propose and use for the Moodle 2.0 themes.
To restrict file linking to images, CSS and JavaScript files to one predefined directory as done in Moodle 2.0 does not help at all - in the opposite it is destructive to our theme design work.
I want to port the "plugin" structure I have developed for my themes to Moodle 2.0. One "plugin" covers a certain topic and contains all CSS, images, JavaScript etc. necessary for this topic in one folder. To use this topic in different themes means to copy the "plugin" folder to another theme and activate it - that's all. With the given Moodle 2.0 theme folder restrictions I can forget the "plugins" and their advantages.
Because I want to continue working with "plugins" I can not accept these restriction. I searched for workarounds - with different success:
$THEME->javascripts[] = '../' . $differentpath . '/modernizr-1.6.min';
$THEME->sheets[] = '../' . $differentpath . '/test';
works in production mode but not in design mode. Moodle strips all path related characters from the given name in design mode. I hacked "styles_debug.php" to deliver CSS in design mode correctly from other directories in the theme folder. For my development installation this solution I can live with for now.To solve the image issue would be quite easy just by adding one condition to the "resolve_image_location" function in the outputlib to set the theme directory as base instead of the pix directory. No existing theme would be touched.
if ($imagefile = $this->image_exists("$this->dir/pix/$image")) {
return $imagefile;
}
// start change uh 2010-11-22
if ($imagefile = $this->image_exists("$this->dir/$image")) {
return $imagefile;
}
// end change uh
Please remove these restrictions within theme folders in Moodle 2.0. They make no sense, as far as I see. But they are a huge annoyance for experienced theme designers.
$THEME->additional_resource_locations = array('relative/location');
Thanks Sam for your detailed explanations.
I didn't want to add additional places to search files. My proposal would be to set the theme folder as base and start each file with a path within the theme folder. In the moment each file type has a different fixed base folder:
This solution demands a bit more typing for theme designers, no additional speed issues and the convenience to use a flexible folder structure which fits the theme needs.
And I think overriding in child themes still works.
And when I understand Moodle caching right file search is only done when a file is not cached. In normal production mode Moodle delivers the compacted files from the cache. This way the place where the files are originally saved does not matter at all.
I created the Moodle Tracker issue MDL-25690 and gave the "feature request" a "Major" priority because for more complex themes a flexible directory structure is essential.
Sam, any new insights from your side?
Everybody who agrees may vote for the issue.
At your proposal to use a "theme" for adding special functionality sounds promising and strange in the same time.
After thinking about your proposal I discover that the way to use a parent theme as "plugin" comes very close to the way I am using the plugins within themes now.
Some questions:
I wrote I find using themes as plugins "strange" because the word theme does not fit with the task of a plugin. A theme is and does much more than a special feature plugin. But this is a communication/terminology and not a development aspect.
Sam, did you have some time to investigate in answers to my questions?
$THEME->name = 'silkicons';
$THEME->parents = array('standard', 'base');
$THEME->sheets = array('silkicons');
// Within the parent lib.php
function theme_parent_dosomething() {
// Heaps of code to do cool stuff.
return $html;
}
?>
// Within the child themes lib.php
function theme_child_dosomething() {
if (function_exists('theme_parent_dosomething')) {
return theme_parent_dosomething();
}
}
I was wondering when someone might answer this post of your Urs...it's taken them long enough.
Needless to say you have my support in all you are asking for on these issues...and I agree with it all, especially the CSS stuff and the fonts too.
Cheers
Mary