Advanced search  

News:

cpg1.5.48 Security release - upgrade mandatory!
The Coppermine development team is releasing a security update for Coppermine in order to counter a recently discovered vulnerability. It is important that all users who run version cpg1.5.46 or older update to this latest version as soon as possible.
[more]

Pages: [1]   Go Down

Author Topic: theme based on user agent  (Read 2472 times)

0 Members and 1 Guest are viewing this topic.

Tranz

  • Dev Team member
  • Coppermine addict
  • ****
  • Country: 00
  • Offline Offline
  • Gender: Female
  • Posts: 6149
theme based on user agent
« on: February 03, 2007, 10:11:03 pm »

I made a theme that's Wii-friendly. I want to use user-agent detection so that it will switch to the wii theme if the wii user agent is detected. However, I can't figure out where to edit the code. I played with the code where the theme selector is but that ended up breaking the theme switching.

Any suggestions on how to go about this?

Thanks.

PS. For the curious, here's how the theme looks like: http://takethu.com/?theme=wii It is designed to be viewable without having to zoom in.
« Last Edit: February 03, 2007, 10:56:53 pm by TranzNDance »
Logged

Nibbler

  • Guest
Re: theme based on user agent
« Reply #1 on: February 03, 2007, 10:27:41 pm »

Add it after here in init.inc.php

Code: [Select]
// Process theme selection if present in URI or in user profile
if (!empty($_GET['theme'])) {
    $USER['theme'] = $_GET['theme'];
}

something like

Code: [Select]
if (user agent is wii) {
    $USER['theme'] = 'wii';
}
Logged

Tranz

  • Dev Team member
  • Coppermine addict
  • ****
  • Country: 00
  • Offline Offline
  • Gender: Female
  • Posts: 6149
Re: theme based on user agent
« Reply #2 on: February 03, 2007, 10:52:35 pm »

Sweet! Thanks for the quick reply.

If anyone else wants to do something similar, here's the code:
Code: [Select]
if (eregi("wii",$_SERVER["HTTP_USER_AGENT"])) {
    $USER['theme'] = 'wii';
}
Logged
Pages: [1]   Go Up
 

Page created in 0.02 seconds with 21 queries.