Testing your new template on a live website

Sooner or later it happens to all of us.
A live website needs to get a new template/layout but you do not want "the public" to see it yet.

This trick allows you to install your new template and make it visible only for you.

Connect to your webspace using FTP and open the root index.php with your favourite editor.

Find the line that show: $wb->get_page_details();

Just before that line insert the following code:

// Sticky Template switcher
if (isset($_GET['template'])) {
   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']);
}

And save the file to your webserver again.

Now you can request your website with a parameter ?template=[newtemplate_dir].
So if your template is located in the directory /templates/mynewtemplate/ use: ?template=mynewtemplate

From that moment on the website will be displayed in your new template (just for you!).

This article is tagged with:
Layout Tutorials Tricks Templates

Related articles

MySQL strict mode > my module will not...

More and more hosting companies are configuring their MySQL servers in strict mode (the default for MySQL 5.7).

Many (older) modules for WebsiteBaker (and even older WebsiteBaker versions) rely on MySQL not being strict.

Read the full article

Problems reaching the WebsiteBaker websites?

The problems with the DNS servers for WebsiteBaker.org are solved. You should have no problems reaching the websites anymore!

Some time ago the master DNS servers of WebsiteBaker were changed. Since that time it is difficult to reach the WebsiteBaker websites for some.

It was reported in the websitebaker forum, but if you cannot connect there you might have missed it.

Read the full article

Comments on this article - Note: comments will be reviewd by a moderator before publishing!

Add your comment

Your name:
Email address:
Website:
Your comment: