Theme switching for mobile

Hi,

I'm trying to figure out the best way to serve a mobile theme/stylesheet for specific devices.

I have a script for detecting the mobile device/browser user agent, but am not sure where to go from there.

The most simple solution would probably be to switch over to a new stylesheet for these devices, which would be easy enough.

But ideally, I think I would like to use an entirely different theme, with modified page templates, etc...

So, I'm wondering if there is an established method for dynamically switching themes?

Thanks -- Erin

This is something we've batted around here at CHNM quite a bit the past few months. There are a number of solutions to this, and we haven't really decided what is the best approach.

All of the solutions will involve using your detection script to set some sort of variable such as $mobile and then checking the status of that.

As you said, the easiest solution would be to use that to load different style sheets. Depending on the general page content that might be fine.

However, if you wanted to alter the content at all (e.g. navigation, smaller files, etc.) there are a couple of alternatives.

First you could run the check at the top of every file and load different content accordingly. So, for example:

<your script>

<?php if $mobile:>

mobile content

<?php else:>

normal content

This way you could load different headers, navigation, page content, etc. pretty easily.

The second way would be to write a plugin that would handle the theme switching. This potentially could make maintenance easier and would certainly make the mobile theme more portable. You could probably come up with a way to do this based on the unreleased Theme Preview Plugin (https://addons.omeka.org/svn/plugins/ThemePreview/trunk/). You could use your script to set the theme name and switch it as such. A plugin would be nice as it would be easy to add configuration for it and would be pretty useful for the Omeka community in general. Obviously it would be more work too. :)

As I said though, this is something we've been discussing for a while, so your thoughts on what you think would be most useful are certainly welcome.