WebsiteBaker Support (2.8.x) > Templates, Menus & Design
Template Switching in v2.8.3
glenpig:
Hi Everyone
We've just upgraded our version of WB to 2.8.3.
In our previous version we added a mobile detect script which set the template to www.url.com/?template=mobile which then displayed a mobile version of the web site.
It doesn't seem to be possible to do this in v2.8.3??? Before you could add "?template=xxxxx" to the end of any page URL and it would switch to that template but this isn't working in 2.8.3
I have installed the templates ok so the directories, files and settings etc are all there.
Any help would be greatly appreciated.
nibz:
--- Quote from: http://www.wbhulp.nl/posts/vanuit-de-website-een-ander-template-kiezen/ translated from dutch to english ---Add the next code in your root index.php before
$wb->get_page_details();
--- Code: ---// Sticky Template switcher
if ($_GET['template']!="") { // get the template to display from URL
if(file_exists(WB_PATH.'/templates/'.$_GET['template'].'/index.php')) {
define('TEMPLATE',$_GET['template']);
$_SESSION['TEMPLATE']=TEMPLATE;
}
} else { // else get the template to display from Session Variable
if(isset($_SESSION['TEMPLATE']) AND $_SESSION['TEMPLATE'] != '')
define('TEMPLATE',$_SESSION['TEMPLATE']);
}
--- End code ---
--- End quote ---
glenpig:
Thanks nibz - that's perfect.
The only thing I'm now getting is a redirection error "too many server redirects" when visiting the site via an Android device. Which is something we didn't get on the previous WB version.
nibz:
1: clear browser cache -> try again.
2: if that doesn't work post the .htaccess content here
nibz:
To no longer display an php notice update the script to:
--- Code: ---// Sticky Template switcher
if (isset($_GET['template'])) { // get the template to display from URL
if(file_exists(WB_PATH.'/templates/'.$_GET['template'].'/index.php')) {
define('TEMPLATE',$_GET['template']);
$_SESSION['TEMPLATE']=TEMPLATE;
}
} else { // else get the template to display from Session Variable
if(isset($_SESSION['TEMPLATE']) AND $_SESSION['TEMPLATE'] != '')
define('TEMPLATE',$_SESSION['TEMPLATE']);
}
--- End code ---
Navigation
[0] Message Index
[#] Next page
Go to full version