Author |
Message |
autonami
Hangin' Around

Joined: Jul 25, 2009
Posts: 26
|
Posted:
Thu Dec 10, 2009 4:12 pm |
|
i was wondering if there was any way to redirect to a certain theme.
i have a piece of code that, when put in the top if index.php it detects a mobile browser, and redirects to a specific URL. i have a somewhat mobile friendly theme on my site, and was wondering if this or a similar script could be used to change the theme automatically upon mobile browser detection.
heres the code that i have that redirects on mobile browser detection.
Code: if(eregi("text/vnd.wap.wml",$_SERVER['HTTP_ACCEPT'])){ header('Location: ./mobile/');}
|
hope my question is easy to understand, and feel free to shoot me down if this has already been discussed. i couldnt find anything about it. |
|
|
|
 |
wHiTeHaT
Life Cycles Becoming CPU Cycles

Joined: Jul 18, 2004
Posts: 579
|
Posted:
Fri Dec 11, 2009 5:19 pm |
|
in your header.php around line 33:
Code:function head() {
global $slogan, $sitename, $banners, $nukeurl, $Version_Num, $artpage, $topic, $hlpfile, $user, $hr, $theme, $cookie, $bgcolor1, $bgcolor2, $bgcolor3, $bgcolor4, $textcolor1, $textcolor2, $forumpage, $adminpage, $userpage, $pagetitle, $name, $db, $prefix, $nukeNAV;
|
Add below:
Code:
if(eregi("text/vnd.wap.wml",$_SERVER['HTTP_ACCEPT'])){
$ThemeSel = 'YOUR MOBILE THEME NAME';
}else{
$ThemeSel = $ThemeSel;
}
|
|
|
|
|
 |
montego
Site Admin

Joined: Aug 29, 2004
Posts: 9457
Location: Arizona
|
Posted:
Sat Dec 12, 2009 9:32 am |
|
Nice one wHiTeHaT.
Just one thing that I am going to start "evangelizing" as much as possible is moving away from Only registered users can see links on this board! Get registered or login!. The POSIX API is deprecated as of PHP5.3 and is discouraged against. Instead, we should be moving towards the PCRE family of functions, in this case, Only registered users can see links on this board! Get registered or login!.
We have our work cut our for us in RavenNuke(tm) to replace these functions.  |
_________________ Only registered users can see links on this board! Get registered or login!
Only registered users can see links on this board! Get registered or login! |
|
|
 |
autonami

|
Posted:
Mon Dec 14, 2009 3:50 am |
|
thanks a lot for you help whitehat. but im not sure if its working... i have yet to test it on a device that has yet to visit my site.
but i cleared history and cache on both my mobile browsers, and it just shows the default theme.
if you guys care to check it out : http://boxlike.com
should i leave the $ThemeSel = get_theme(); under the code you gave me?
im going to assume that the preg_match function wouldnt work with the current version of RN. ? |
|
|
|
 |
wHiTeHaT

|
Posted:
Mon Dec 14, 2009 1:16 pm |
|
I checked to see if your site worked with the tweak , and it seems it doesnt.
So i tryed over and found the solution ( i think).
make a backup of your mainfile.php
Then open it in your text editor and replace the complete function
function get_theme()
I assume your themename is "boxlike_mobile_beta"
Code:function get_theme() {
global $user, $db, $prefix, $user_prefix, $Default_Theme;
static $theme = false;
if ($theme) return $theme;
$theme = (isset($_COOKIE['theme'])) ? base64_decode($_COOKIE['theme']) : false;
if(eregi('text/vnd.wap.wml',$_SERVER['HTTP_ACCEPT'])){
$theme = 'boxlike_mobile_beta';
return $theme;
}else{
if (isset($_POST['themeprev']) && $theme != $_POST['themeprev'] && file_exists('themes/'.$_POST['themeprev'].'/theme.php')) {
$theme = $_POST['themeprev'];
setcookie('theme',base64_encode($theme), 0);
if (is_user($user)) {
$user2 = explode(':', base64_decode(addslashes($user)));
$user_id = intval($user2[0]);
$info = base64_encode("$user2[0]:$user2[1]:$user2[2]:$user2[3]:$user2[4]:$user2[5]:$user2[6]:$user2[7]:$user2[8]:$theme:$user2[10]");
setcookie('user', $info, time()+2592000);
$db->sql_query('UPDATE '.$user_prefix.'_users SET theme=\''.$theme.'\' WHERE user_id=\''.$user_id.'\'');
}
return $theme;
} elseif ($theme && file_exists('themes/'.$theme.'/theme.php')) {
return $theme;
}
if (!is_user($user)) {
$theme = $Default_Theme;
return $theme;
}
$user = addslashes($user);
$user2 = base64_decode($user);
$user2 = explode(':', $user2);
if($user2[9]) {
if(!file_exists('themes/'.$user2[9].'/theme.php')) {
$theme = $Default_Theme;
} else $theme = $user2[9];
} else $theme = $Default_Theme;
return $theme;
}
}
|
i have tested it on one of my own site's and it worked.
However keep in mind the current wap devices use the common browser functions , so not all portable devices sending the mobile identification.
Goodluck |
Last edited by wHiTeHaT on Mon Dec 14, 2009 3:54 pm; edited 2 times in total |
|
|
 |
wHiTeHaT

|
Posted:
Mon Dec 14, 2009 1:21 pm |
|
There is also an addon for Firefox, so you can use WAP from within your browser, quite handy.
Only registered users can see links on this board! Get registered or login!
Make sure you set in the add-on options to enable "Tell websites that the browser understands WML content" |
|
|
|
 |
wHiTeHaT

|
Posted:
Mon Dec 14, 2009 4:16 pm |
|
i have edited the code above couse i left some test variables in it
just remove the $mytest1 instances and you are good.
There's 1 in the global line and one in the middle of the function.
But i wanted to tell you there excist a module called wap2go , it seems like the dev is starting to make it rn compatible.
you can check it here: Only registered users can see links on this board! Get registered or login! |
|
|
|
 |
autonami

|
Posted:
Mon Dec 14, 2009 8:30 pm |
|
well, i believe that did the trick sir. thats awesome, thanks a lot for the help and the prompt feedback. this was very helpful to my site.
i actually have the wap2go installed on my site. but it doesnt work. apparently some things in the 2.3 RN config file didnt match up with the latest release of wap2go which was released in dec 2007. and he is a very busy guy and doesnt give much feedback either. ive tried all kinds of stuff and all i get is this error, "Unable to locate the RavenNukeā¢ configuration file - INCLUDE_PATHrnconfig.php " when trying to access the module.
thanks again bro. |
|
|
|
 |
nuken
RavenNuke(tm) Development Team

Joined: Mar 11, 2007
Posts: 2024
Location: North Carolina
|
Posted:
Tue Dec 15, 2009 12:30 pm |
|
I posted the fix for that on the wap2go forums. |
_________________ Only registered users can see links on this board! Get registered or login! |
|
|
 |
autonami

|
Posted:
Tue Dec 15, 2009 9:35 pm |
|
nuken wrote: | I posted the fix for that on the wap2go forums.
To define the rnconfig.php file, open mobile/includes/w2g_mainfile.php and paste
Code:
if(!defined('INCLUDE_PATH')) define('INCLUDE_PATH', '../../');
under
Code:
@include("settings.php");
so it will look like this
Code:
<?php
/******************************************************************************/
/* Wap-2-Go Mobile Phone Nuke-Addon */
/* bringing the Advanced Content Management System to Mobile Format */
/* ==========================================================================*/
/* powered by Nuke Database */
/* */
/* Copyright (c) 2007 by Philip Marsh - http://www.wap2go.co.uk */
/* */
/* FILE DETAILS and EXPLANATION: */
/* w2g_mainfile.php - Specific Functions for Mobile Site */
/******************************************************************************/
@include("settings.php");
if(!defined('INCLUDE_PATH')) define('INCLUDE_PATH', '../../');
This way if the CMS is not RavenNuke(tm), it will still work. |
i put this in like you said. and it gave me another error
Unable to locate the RavenNuke(tm) configuration file - ../../rnconfig.php
**edit** i changed ('INCLUDE_PATH', '../../') to ('INCLUDE_PATH', '../') ( only one '../' and it works. outstanding. thanks a lot nuken. now i get to start moding this mod with a fancy theme and layout and such. |
|
|
|
 |
nuken

|
Posted:
Tue Dec 15, 2009 9:54 pm |
|
Oh yes, I had it on a sub domain and needed the extra ../ I'm glad you got it working. |
|
|
|
 |
helidoc
Hangin' Around

Joined: Jul 09, 2006
Posts: 49
|
Posted:
Wed Feb 10, 2010 8:00 am |
|
Anyone have Wap2Go working on a 2.40 site was thinking of adding this for some of my Mobile users. |
|
|
|
 |
|