WebsiteBaker Support (2.8.x) > Templates, Menus & Design
I need the template switcher code
kweitzel:
has not been done yet to my knowledge, but with the code here and reformating the output of the men calls you could achieve this functionality.
cheers
Klaus
raspi:
Thx for the help - now I got it (at least the first step)
Now I only need to add a choose box for all installed templates.
For the ones looking for similar - here the code I used:
--- Code: ---// get the template to display from URL
if ($_GET['template']!="") {
if(file_exists(WB_PATH.'/templates/'.$_GET['template'].'/index.php')) {
define('TEMPLATE',$_GET['template']);
$_SESSION['TEMPLATE']=TEMPLATE;
}
}
// get the template to display from Session Variable
else {
if(isset($_SESSION['TEMPLATE']) AND $_SESSION['TEMPLATE'] != '')
define('TEMPLATE',$_SESSION['TEMPLATE']);
}
--- End code ---
I just add another $SESSION variable.
Vincent:
That sounds interesting, raspi. Please let us know when it is up and running, I'd very much like to see it in action.
Good luck,
Vincent
Luckyluke:
Hi,
This is an old post. But is this already developed?
Someone used this or any other code?
Or can this be done with a droplet? I see this droplet but I do not quite.
Grtz,
Luc
Vincent:
Hi Luc,
yes, the code as described in the post above works. I haven't tested the droplet, but it seems to do the same thing.
For implementing the code described in this post, change your root index file from
--- Code: ---// Collect info about the currently viewed page
// and check permissions
$wb->get_page_details();
--- End code ---
to
--- Code: --- // Collect info about the currently viewed page
// and check permissions
// 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']);
}
$wb->get_page_details();
--- End code ---
and you're done. Call the template through www.yourdomain.com/?template=template-name
Regards,
Vincent
Navigation
[0] Message Index
[#] Next page
[*] Previous page
Go to full version