Question
Is there any way to select a skin depending on the browser of the user (HTTP_USER_AGENT) ?
We use a modified pattern skin as default, which looks fine on modern browsers. But we have quite a number of users who still stick to netscape 4.x, which looks ugly with the pattern skin but should use e.g. the classic skin. Unfortunately, these users would also not be able/willing to create their own user profile with an adequate skin setting. Therefore, I would like to select the skin depending on the client browser in order to help even these users to use our new TWiki site (which is just under development)
Environment
--
JChristophFuchs - 05 Oct 2004
Answer
I found a very brute solution: In the
view script I check, if no skin preference ist given in the URI and if HTTP_USER_AGENT is of the form Mozilla/
version with
version < 5. If yes, I set a new skin preference in the URI:
if (! $query->param( 'skin' ) &&
$query->user_agent =~ m|^Mozilla/(\d+)\.| &&
$1 < 5 ) {
$query->param( 'skin', 'classic');
}
This works unless a user has a personalised setting of the SKIN preference variable, which also gets overwritten.
I think there must be a better solution, e.g. from within a plugin.
--
JChristophFuchs - 11 Oct 2004
Ooooh .... tricky.
I would say that for your purposes your solution is correct. I don't
think there's any alternative recommended approach.
There's a choice here. You can either make the skin smart enough to handle antediluvian and abstract browsers (very hard) or do what you have done and select an alternate skin, based on a fallback sequence e.g.
- Set SKIN = /Mozilla[1234]/ ? Classic : /MSIE3/ ? Dragon : Pattern
I'd go for this option myself. It should be pretty straightforward to code. Try it and see! We await your patch with interest!
--
CrawfordCurrie - 11 Oct 2004

Ideas, requests, problems regarding TWiki?
Send feedback. Ask community in the
support forum.
Copyright © 1999-2026 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.