Mobile theme url

I'd like to add a mobile theme url, eg.

to an existing Elgg site at

The two sites should share the same database and differ only in the theme used.

This seems to be a common approach for other apps but I'm uncertain how to teach Elgg to use two different URLs for the same site. Has anyone done this successfully? How would it work?

  • Kevin, why it needs to be a subdomain? Why cant an existing mobile plugin be used? Just sniff the browser and then set the view appropriately?

  • Mobile devices now vary wildly in their resolutions and capabilities. The subdomain method allows users with more capable devices to over-ride the mobile domain and visit the regular site.


  • You should maybe consider the responsive solution.


  • Gillie, I have looked at responsive design, but there are two problems I see with that approach:

    a. The desktop theme already exists and we don't want to make major changes to it, and

    b. Most responsive designs I have seen really look like they are designed for mobile devices (large fonts, very simple navigation) and they also happen to work for desktops. Sort of the Windows 8 approach. :) I'm not sure that I like the Windows 8 approach. I prefer the two different designs approach.


  • To follow up more on Mohammed's question. I'm not sold on the idea of a subdomain. I just want an easy way for users to switch back and forth between the two designs. Perhaps this could be via a cookie on their device rather than a subdomain? I could use the user-agent to select the theme unless the cookie is set.

  • a. That's the point with responsive layout. Use the existing theme and let it adapt to screen size. I have a demo here,


  • @kevin - not sure if it is the best approach, but I used a script to detect device being used and then built out a specific mobile theme which was called instead of default when that device was used. Have also used responsive, either way, it is a lot more work than it might appear to get a great mobile experience. 

    My mobile theme was in /views/mobile

  • @ gillie - Nuevo is a very nice responsive theme, but it seems that it works so well because there is almost no user interface. Responds well and looks great, but I see Kevin's point about very simple navigation, too simple. I've been worrying about this problem also. There are so many different resolutions being used. The best scenario is a one column layout, navigation at top, that can be responsive well enough to cover all resolutions. Shane Barron made a step in the right direction today by uploading this theme that has a new layout.

  • Dave's approach will work pretty well, but might be a pain if you want the user to click back to the main template. Of course, a cookie or a session variable might help there.

    I'd be tempted to try creating a server vhost with both and listed as addresses, and hook into the server hostname ($_SERVER['SERVER_NAME']) at the end of the init process. If it's, switch to your mobile template and flip the wwwroot in the config variable to your mobile domain. Otherwise, do nothing. Feeds might be a little extra work here.