Themes

 
 
Picture of Trevor Johnson
Force a different mobile or tablet theme than the main site mobile theme
 

I know you can force a different theme for a course for the standard browsers, in course settings just select the required theme from the Force theme DD list.

But what about for mobile devices?

Is it possible to use different theme for mobile devices on a course by course basis?

 
Average of ratings: -
It's only an avatar...
Re: Force a different mobile or tablet theme than the main site mobile theme
Group DevelopersGroup Documentation writersGroup Particularly helpful MoodlersGroup Testers

In a 'Nut shell' no!

 
Average of ratings:Useful (1)
Picture of Trevor Johnson
Re: Force a different mobile or tablet theme than the main site mobile theme
 

So, I was working on a Moodle to Mahara linking single-sign-on issue we have, and I noticed a Moodle PHP page called switchdevice.php in the moodle/theme folder, I looked inside a found this function “set_user_device_type($newdevice);”.

So naturally that got my attention.

After a bit of poking around I found there is a method of changing the theme by using a specially crafted URL.

And it's even documented, http://docs.moodle.org/25/en/Theme_settings#Allow_theme_changes_in_the_URL, so I should have RTFM...

So if you want to force a different theme on a course by course basis you can, just add the theme required to the URL, the browser uses that theme until forced to another theme, and this works for all for all devices types.

Problem solved…

 

 
Average of ratings: -
It's only an avatar...
Re: Force a different mobile or tablet theme than the main site mobile theme
Group DevelopersGroup Documentation writersGroup Particularly helpful MoodlersGroup Testers

There is a setting in Site Admin > Appearance > Themes > Theme setting called "Allow theme change by URL" so you would need to enable that first unless you plan to add that setting directly in your Moodle site root config.php?

Here is an earlier bit of documentation about the same thing, found further down the document you linked to:

http://docs.moodle.org/25/en/Theme_settings#Session_themes

And yes that will work, but it is not automatic, which is what you asked for originally. To achieve the theme change by url, however, you would need to add a link in a course either directly in the course page, per topic even, or in a block on that course page. There are two methods to doing this. The first is achieved by adding ?theme=afterburner (to use the afterburner theme) the other method when incourse so to speak is achieved by adding &theme=afterburner

Anyway, thanks for pointing this alternative method out. I should have directed you to that page in the first place as I am very familiar with it, so my apologies in that regard.

On another related note, I would like to know how the Page theme works, which is also very briefly documented in that same link. I have never really understood the concept, perhaps you might like to play with that as well and tell us how it's done.

yeah!

Cheers

Mary

 
Average of ratings: -