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:
- JavaScript was easy - adding "../" and the new path to the array in the theme config file does the trick like
$THEME->javascripts[] = '../' . $differentpath . '/modernizr-1.6.min'; - CSS gave some issues. adding "../" and the new path to the array in the theme config like
$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. - Images I could not find any workaround for using the great Moodle file caching system. The only way around for me is to deliver the images directly with a CSS rule like "background: #fcfcfc url('custom:themedirurl/themename/differentpath/img/noise.png'); and a function for "csspostprocess" to replace custom:themedirurl with the URL to the theme folder. Quite bad, isn't it?
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.