- This topic is empty.
-
AuthorPosts
-
January 9, 2013 at 3:26 pm #41881tigertonMember
Hi!
Could really use some brains on this one..
I’ve used this article:
http://digwp.com/2009/12/redirect-mobile-users-to-mobile-theme/
to create a plugin which switches the theme, frontpage etc. with filters. the filters I use are these://filters for changing the theme
add_filter(‘template’, ‘stgr_filter_switchTheme’);
add_filter(‘option_template’, ‘stgr_filter_switchTheme’);
add_filter(‘stylesheet’, ‘stgr_filter_switchTheme’);//If we’ve set a different frontpage, run filter to change frontpage
if($options != ”){
add_filter(‘option_page_on_front’, ‘tgr_filter_switchFrontpage’);
add_filter(‘option_show_on_front’, ‘tgr_filter_switchShowonfront’);
}
//If we’ve set a different blogpage, run filter to change blogpage
if($options != ”){
add_filter(‘option_page_for_posts’, ‘tgr_filter_switchBlogpage’);
}But I also need a way for a mobile user to see the whole site instead if they click a link in the mobile version. What I had in mind was to have the link pass a GET variable in the URL and in the wp_config.php I check for the variable and if its set I set a session variable.
session_start(); // start up your PHP session!
$desktop = $_GET;
if($desktop == ‘desktop’){
$_SESSION = ‘desktop’; // store session data
}I then figured I could check for this session variable in the plugin and if it’s present I don’t want to run the filters.
However it does not seem to work! I’m probably thinking about this the wrong way.. If any of you guys have a solution I would be very grateful!
January 9, 2013 at 3:40 pm #120431tigertonMemberThe thing is that the desktop-version is going to be completely responsive as well..However the client want a VERY different mobile-version which looks basically like a webapp which one can save to homescreen.
I prefer not to create a different installation for it to make it as simple as possible for the client.
It’s also working like a charm, just switching the theme and front-page and voila, I can create a completely different site from the same wp. Now I just need to be able to reverse the filters and maintain that.January 9, 2013 at 6:48 pm #120450ToxicFireParticipantis get actually pulling version in? ie is the problem with it been stored in the session or it actually been passed too the page in the url.
Also could we have an example of the link your using to pass the version.January 10, 2013 at 3:10 am #120494tigertonMemberYeah The GET is pulling version in and it is indeed setting the session variable.
The url of the link looks like
http://xxxxxxxxx.com/?version=desktopIF this way is possible I think my issue lies with how I handle the filters. Does anyone know wether these filters apply before browser rendering or not? I can see how it would be an issue if not since what I want is just to disable the browser rendering filters if the visitors session is stored.
January 10, 2013 at 10:32 am #120526tigertonMemberOkay just to post the “answer” for anyone interested..
My code does work as is. There was another piece of code which interfered with my solution. So basically.. What I’ve described above works like a friggin charm if anyone needs a similar solution.
In summary what I do is:
* Use the script found here: http://detectmobilebrowsers.mobi/ to detect if a user is on a mobile
* Run the filters to change the theme and frontpage etc. before browser rendering
* If user clicks “show desktop version”. Pass a parameter “?version=desktop” in the url to the frontpage.
* In wp-config.php, I check if this parameter is set, if so I set a php session variable.
* If the session variable is set, I don’t run the previous filtersThis gives me the possibility to create a completely different mobile version which in my case is used as a webapp. It uses the same wordpress installation and database but a different theme and frontpage. Awesomesauce!
-
AuthorPosts
- The forum ‘Back End’ is closed to new topics and replies.