Main Theme vs. Module Specific Theme?

Main Theme vs. Module Specific Theme?

by N Hansen -
Number of replies: 3
In 1.5, there appears to be the main theme CSS files and then module-specific CSS files. Why? And if a certain property is controlled by one of the module-specific files, and I wish to change it, what should I do? Is it better to hack the module-specific file, or put it in the main files? Which takes priority over the other? For example, what do I do with this from the choice styles.php if I wish to change the border-color, or add a different background color?

.mod-choice .results .data {
  border-width:1px;
  border-style:solid;
  border-color:#999;
}
Average of ratings: -
In reply to N Hansen

Re: Main Theme vs. Module Specific Theme?

by Michael Penney -
One issue here is that the main css is huge and getting huger. 50k worth of css to load the main site page. It's pretty hard to find and edit mod styles in these huge files. If the styles for individual module layout are local to the module, then  it is much easier (IMO) to find and edit modular styles.

At some point it would be nice if we could figure a way for the mods not to load their styles until they are actually visited, this could reduce the initial load time (on a modem) of a Moodle site  a bit.
In reply to Michael Penney

Re: Main Theme vs. Module Specific Theme?

by N Hansen -
Michael-I don't know if it would be of a help in a large installation like yours where you have lots of different users needing different things, but I am just modifying the standardtheme to look like what I have in 1.4. I've had to add a few things that aren't there, but I've also deleted a number of things that I don't need at this time, such as styles for modules and features I'm currently not using, as well as the comments in the code. This cuts down on filesize somewhat 
In reply to N Hansen

Re: Main Theme vs. Module Specific Theme?

by Urs Hunkler -
Picture of Core developers

Hi Nicole,

"... then module-specific CSS files. Why?"

The module specific CSS files help keeping the main CSS files smaller. Some very special basic layout information especially for non standard blocks and modules would let the main CSS files unnecessarily grow. Used wisely the module-specific CSS files are a great help for the Moodle CSS system.

"And if a certain property is controlled by one of the module-specific files, and I wish to change it, what should I do?"

You better "... put it in the main files". Your CSS files contain your specific mixture of all the styling you want to apply or to add to your Moodle. Just overwrite all properties of the included CSS files with your properties in your CSS files. Your CSS files come last in the loading order, so overwriting is no problem.

Please look also at this discussion.

@Penny
"If the styles for individual module layout are local to the module, then it is much easier (IMO) to find and edit modular styles."

As I answered Nicole and you can read in Martins posting in the above mentioned thread only very basic styles should go into the module-specific CSS. If the styles are spread it will be hard to keep the overview.

"At some point it would be nice if we could figure a way for the mods not to load their styles until they are actually visited..."

This would be a big advantage. The CSS files will still keep growing, because some areas of Moodle still have got hardly any hooks.