WebsiteBaker Support (2.8.x) > Templates, Menus & Design

I need the template switcher code

<< < (2/7) > >>

kweitzel:
I don't know about session variables, but what you could actually do is modify the menu output to display the template part to achieve this (as a temporary workaround).

cheers

Klaus

tomhung:
thanks that exactly what i'm looking for.....

DGEC:
I cannot figure out what's up with this, not sure where to put this in the index file. How does this work?  I thought that it should just redefine the value in the TEMPLATE variable.

Where does TEMPLATE get loaded then?

I've tried it before and after the existing code:

--- Code: ---require(WB_PATH.'/templates/'.TEMPLATE.'/index.php');
--- End code ---

I've tried putting it in an IF statement, copying the require, echo'd the results...

The other template is found in correct directory & displays if echoed, but nothing will change my existing template display.

Tried putting the existing "require" as an else to the template != and the page is empty - nothing but the body. I thought maybe the define was creating a constant, so I added it too...

At first I was putting it in the active template's index.php itself, which didn't work either.

Here's what I've put in the main wb/index.php file:


--- Code: ---if ($_GET['template']!="") {
   if(file_exists(WB_PATH.'/templates/'.$_GET['template'].'/index.php')) 
   {
      define('TEMPLATE',$_GET['template']);
require(WB_PATH.'/templates/'.TEMPLATE.'/index.php');
   }
}

require(WB_PATH.'/templates/'.TEMPLATE.'/index.php');
--- End code ---

marathoner:
Simply insert the 3 lines of code that I mentioned above in your wb/index.php file. I inserted the code between "$wb->page_select() or die();" and "$wb->get_page_details();". Here's a snippet from my wb/index.php file:

--- Code: ---// Figure out which page to display
// Stop processing if intro page was shown
$wb->page_select() or die();

// Figure out what template to use - DFD allows 'template' variable in the URL to call a different template
if ($_GET['template']!="")
if(file_exists(WB_PATH.'/templates/'.$_GET['template'].'/index.php'))
define('TEMPLATE',$_GET['template']);

// Collect info about the currently viewed page
// and check permissions
$wb->get_page_details();

--- End code ---

To use this feature simply append the TEMPLATE variable to your URL to let it know which template you want to display that page with. For example, to display your home page using the ALLCSS template you would enter your URL into your browser as:
http://www.mydomain/pages/home.php?template=allcss

raspi:
Does somebody know a way to permanently change the tempalte also for the other pages of a site.
Let's say somewhere I put a dropdown box on the "Home" page - the user switches to another template and from now on (for this browser session only) - he surfs the site with the chosen template.

Like to online test of Joomla for example. That would be a good way to demonstrate different templates to a Customer.

Navigation

[0] Message Index

[#] Next page

[*] Previous page

Go to full version