Template Switching in v2.8.3

glenpig

Thanks for all your help nibz

All seems to be working now!

I had ordered the code so that the mobile detect script was included before your sticky template script. Looking back at the previous WB that we were using, it was the other way around (sticky template first followed by mobile detect).

So I swapped the order over and all seems to be working well now!

nibz

To no longer display an php notice update the script to:


// 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']);
}

nibz

1: clear browser cache -> try again.

2: if that doesn't work post the .htaccess content here

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

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();


// 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']);
}


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.