theme based on user agent theme based on user agent
 

News:

CPG Release 1.6.27
change DB IP storage fields to accommodate IPv6 addresses
remove use of E_STRICT (PHP 8.4 deprecated)
update README to reflect new website
align code with new .com CPG website
correct deprecation in captcha

Main Menu

theme based on user agent

Started by Tranz, February 03, 2007, 10:11:03 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Tranz

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.

Nibbler

Add it after here in init.inc.php


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


something like


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

Tranz

Sweet! Thanks for the quick reply.

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