I'm having to build a site that renders different content depending on device being used. Ideally I'd like the server to be able to determine the device and serve up the relevant template (thereby avoiding rendering rendundant elements on mobile devices).
I'm thinking that I'd build the site, assign the default templates and then within the master template, run a server-side check to see the device and then switch the template based on a simple name convention ie:
var template = GetCurrentTemplate(); if desktop load regular template else if ipad load template + "-ipad" else if mobile load template + "-mob"
So for every template I'd have an ipad/mobile one created too. I'd somehow detect the device on the server and then render the correct template.
Is this a viable approach? Has anyone managed to do something like this?
The only major problem I can forsee is the url-rewriting.. is it possible to create a url-rewriting rule that'd strip the altTemplate querstring from the browser window?
Thanks Rich but I'm not sure if that's what I'm after. It'd be fine if I just had one set of mobile templates to worry about as I could redirect to a mobile specific domain and serve up the correct templates.
The issue I'm having is that I have 5 different templates that need to be rendered for different devices/resolutions. From what I gather, if I was to take the above approach I'd have to have 5 separate content trees, with each tree having a different hostname for that particular device? Combine that with the fact I have two languages, that'd mean 10(?!) trees?
I figured the easiest thing would be to have two content trees for each language, and then in the umbraco masterpage run a check to figure out what device is viewing the site, then render the content with the correct template. It seems I might be able to do this using the altTemplate querystring but I wonder if anyone has done this before and if so, how it worked out? Also, is it possible to load a template programmatically? I can't seem to find any info on it..
Mobile websites and altTemplates
Hi guys,
I'm having to build a site that renders different content depending on device being used. Ideally I'd like the server to be able to determine the device and serve up the relevant template (thereby avoiding rendering rendundant elements on mobile devices).
I'm thinking that I'd build the site, assign the default templates and then within the master template, run a server-side check to see the device and then switch the template based on a simple name convention ie:
var template = GetCurrentTemplate();
if desktop
load regular template
else if ipad
load template + "-ipad"
else if mobile
load template + "-mob"
So for every template I'd have an ipad/mobile one created too. I'd somehow detect the device on the server and then render the correct template.
Is this a viable approach? Has anyone managed to do something like this?
The only major problem I can forsee is the url-rewriting.. is it possible to create a url-rewriting rule that'd strip the altTemplate querstring from the browser window?
Hey,
You might want to check out this project http://our.umbraco.org/projects/website-utilities/51degreesmobi-mobile-device-detection-and-redirection
Rich
Thanks Rich but I'm not sure if that's what I'm after. It'd be fine if I just had one set of mobile templates to worry about as I could redirect to a mobile specific domain and serve up the correct templates.
The issue I'm having is that I have 5 different templates that need to be rendered for different devices/resolutions. From what I gather, if I was to take the above approach I'd have to have 5 separate content trees, with each tree having a different hostname for that particular device? Combine that with the fact I have two languages, that'd mean 10(?!) trees?
I figured the easiest thing would be to have two content trees for each language, and then in the umbraco masterpage run a check to figure out what device is viewing the site, then render the content with the correct template. It seems I might be able to do this using the altTemplate querystring but I wonder if anyone has done this before and if so, how it worked out? Also, is it possible to load a template programmatically? I can't seem to find any info on it..
Ta
is working on a reply...