Affects Version/s: 3.7
Fix Version/s: 3.8
Install the change_css_urls branch of theme_picture plugin into your moodle instance:
- cd theme/
- git clone -b change_css_urls email@example.com:bmbrands/theme_picture.git picture
- cd ..
- php admin/cli/upgrade
- enter yes to upgrade
Select theme picture:
Login as AdminInstall the change_css_urls branch of theme_picture plugin into your moodle instance: cd theme/ git clone -b change_css_urls firstname.lastname@example.org:bmbrands/theme_picture.git picture cd .. php admin/cli/upgrade enter yes to upgrade Select theme picture: Login as Admin Navigate to Site Administrations > Appearance > Theme selector Select theme Picture to be your default theme Navigate to "Site home" Change the url in your browser from http://yourmoodle.local/?redirect=0 to http://yourmoodle.local/?redirect=0&preset=dark Verify the theme now shows a dark preset.
Pull from Repository:
Pull Master Branch:
Pull Master Diff URL:
Core css url's are used to server css files to the end user. In Moodle core they look something like this:
The styles.php file checks if a URL exists and if the cached version of the css file can be served or if a new css file needs to be generated. For the boost theme this results in recompiling scss to css, caching the new version and serving it back to a client.
This means a theme can only ever generate one CSS file which is identical to all clients.
In a use-case where a smart theme needs to serve a different css file for different pages or context the only option now is to copy the theme to a theme with another name and have the new theme serve a different css file.
This is not very flexible and a lot of work especially when all we need is some different sass variables like the $primary colour that is referenced a lot in bootstrap scss and Moodle core scss files.
The suggested change is just one line, thanks to Marina Glancy and does not affect existing themes. It has been used on the Moodle for workplace and the Moodle.org themes.