WebsiteBaker Logo
  • *
  • Templates
  • Help
  • Add-ons
  • Download
  • Home
*
Welcome, Guest. Please login or register.

Login with username, password and session length
 

News


WebsiteBaker 2.13.6 is now available!


Will it continue with WB? It goes on! | Geht es mit WB weiter? Es geht weiter!
https://forum.websitebaker.org/index.php/topic,32340.msg226702.html#msg226702


The forum email address board@websitebaker.org is working again
https://forum.websitebaker.org/index.php/topic,32358.0.html


R.I.P Dietmar (luisehahne) and thank you for all your valuable work for WB
https://forum.websitebaker.org/index.php/topic,32355.0.html


* Support WebsiteBaker

Your donations will help to:

  • Pay for our dedicated server
  • Pay for domain registration
  • and much more!

You can donate by clicking on the button below.


  • Home
  • Help
  • Search
  • Login
  • Register

  • WebsiteBaker Community Forum »
  • WebsiteBaker Support (2.8.x) »
  • Templates, Menus & Design »
  • Template Switching in v2.8.3
  • Print
Pages: [1]   Go Down

Author Topic: Template Switching in v2.8.3  (Read 8900 times)

Offline glenpig

  • Posts: 6
Template Switching in v2.8.3
« on: February 08, 2014, 03:48:14 PM »
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.
Logged

Offline nibz

  • Posts: 684
  • Gender: Male
Re: Template Switching in v2.8.3
« Reply #1 on: February 08, 2014, 04:38:19 PM »
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: [Select]
// 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']);
}
Logged

Offline glenpig

  • Posts: 6
Re: Template Switching in v2.8.3
« Reply #2 on: February 08, 2014, 06:13:26 PM »
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.
Logged

Offline nibz

  • Posts: 684
  • Gender: Male
Re: Template Switching in v2.8.3
« Reply #3 on: February 08, 2014, 07:44:34 PM »
1: clear browser cache -> try again.

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

Offline nibz

  • Posts: 684
  • Gender: Male
Re: Template Switching in v2.8.3
« Reply #4 on: February 13, 2014, 05:19:01 PM »
To no longer display an php notice update the script to:

Code: [Select]
// 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']);
}
Logged

Offline glenpig

  • Posts: 6
Re: Template Switching in v2.8.3
« Reply #5 on: February 14, 2014, 04:55:12 PM »
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!
Logged

  • Print
Pages: [1]   Go Up
  • WebsiteBaker Community Forum »
  • WebsiteBaker Support (2.8.x) »
  • Templates, Menus & Design »
  • Template Switching in v2.8.3
 

  • SMF 2.0.19 | SMF © 2017, Simple Machines
  • XHTML
  • RSS
  • WAP2