How can I use a color variable in the styles.css file of an activity

Re: How can I use a color variable in the styles.css file of an activity

by AL Rachels -
Number of replies: 0
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Testers

Well, I guess I cheated by using two css files, and have it working with just five lines of new code. One css file is a master template, and the other, is the actual styles.css file that gets used anytime someone views a MooTyper activity.

Don't know if the way I did it is quite kosher, though. What do ya'll think? I added code at the bottom of the settings.php file. I also had to rewrite the color picker so it includes 'theme_reset_all_caches' so everyone can see the change without admin having to purge all caches.

$old = 'setting:keyboardbgc';
$new = get_config('mod_mootyper', 'keyboardbgc');
$data = file_get_contents($CFG->dirroot.'/mod/mootyper/template.css');
$newdata = str_replace($old, $new, $data);
file_put_contents($CFG->dirroot.'/mod/mootyper/styles.css', $newdata);

I checked some page load times, with the and without the code enabled and don't see any significant time change, either way. Doesn't really matter I would think, as this is a setting that will rarely be used.

Should make it really easy to add a color picker for the non-home row keys too.