dualcube / moodle-theme_crisp

A Crisp Bootstrap Theme for Moodle
0 stars 3 forks source link

Theme doesn't work when specifying theme in URL #1

Closed michael-milette closed 9 years ago

michael-milette commented 9 years ago

If my current theme is set to 'clean' and I have enabled the option of specifying the theme name in the URL using the ?theme=crisp syntax, I get the following error in Moodle 2.7:

image

I've tracked down the problem to the following lines in layout/header.php:

$PAGE->requires->js('/theme/'.$CFG->theme.'/javascript/font.js'); $PAGE->requires->js('/theme/'.$CFG->theme.'/lemmon-Lemmon-Slider/lemmon-slider.js'); $PAGE->requires->js('/theme/'.$CFG->theme.'/javascript/crispy.js');

Turns out that $CFG-theme does not reflect the name of the displayed theme when using the URL to override it.

For now, I've replaced '.$CFG->theme.' with crisp which allows the theme to work however you have used the same technique for many of the images in the theme which will also need to be fixed.

If you don't want to hard code the theme name, I would suggest declaring a variable and assigning it the theme name. Then you could use the variable throughout your code without worrying about what might happen if you change it.

Alternatively, I think you can get the current theme name by using the following code:

 global $SESSION;
 $defaulttheme = !isset($SESSION->theme) ? core_useragent::get_device_type_theme() : $SESSION->theme;
 $defaulttheme =  optional_param('theme', $defaulttheme, PARAM_THEME);

Best regards,

 Michael
parthajeet commented 9 years ago

Hello Michael,

Thanks for the update. Surely we will update this in our next version.

Thanks and Regards, parthaJeet~

vaughany commented 9 years ago

Just seen this error on our test Moodle 2.9 installation. Do you know what the fix is, or roughly when your next version is being released?

parthajeet commented 9 years ago

Hello Paul,

Yes, we will fix this in our next version.

Thanks, parthaJeet~