WebsiteBaker Community Forum

WebsiteBaker Support (2.8.x) => Templates, Menus & Design => Topic started by: Ale on November 03, 2008, 12:05:14 PM

Title: How to preview template?
Post by: Ale on November 03, 2008, 12:05:14 PM
I'm about to make some major changes to my page template. Is it possible to somehow privately preview the template in the admin section, while retaining the old template for anyone who visits the public pages? This way I could make some final touches to the template while seeing the real page content, but anyone else who visits the page would still see the old one.
Title: Re: How to preview template?
Post by: Stefek on November 03, 2008, 12:14:39 PM
Hello!
The best way to do this, is a local installation with xampp.

After you made all your changes, you can upload the template again to the live server.

Regrads,
Stefek
Title: Re: How to preview template?
Post by: Ale on November 03, 2008, 12:31:08 PM
Ok thanks. That was exactly what I wanted to know.

The only downside of the method is that you must have 100% similar database and custom modules to view the template with similar content as in live web site.
Title: Re: How to preview template?
Post by: Ruud on November 03, 2008, 12:45:13 PM
You could do a search here in the forum for "template switcher".

There are some solutions out there where you can switch just by using a parameter on the url.
You need to upload your new template with a different name/path and make a small change in your root/index.php.

That way you can view your complete site with any other template.

Ruud

Title: Re: How to preview template?
Post by: Stefek on November 03, 2008, 12:52:14 PM
@Ale

Yes, that's right.
For future Projects I advice you to set up a local installation first (whith all modules you will need), then to create your Template and then to create the Content on a live server.

With some experience you will find the "Golden Recipe" to bake your Websites with Webitebaker.

@Ruud -
this is another good advice. But  if you want to make more changes and also in the Module Files it cost more time, I guess.

Regards,
Stefek

Title: Re: How to preview template?
Post by: Ruud on November 03, 2008, 01:25:11 PM
Maybe the combination is the best solution ;-)

Do your template development on a XAMPP/WAMP server (like most of us do). That is convenient and faster editing and previewing.
If you really want to test first on your live server, use the template switcher solution for a live check.

Ruud
Title: Re: How to preview template?
Post by: Ale on November 03, 2008, 02:09:39 PM
Thank you all for your input.

I discovered a another way. The file class.frontend.php defines which template to use. I just added this code:

Code: [Select]
if(isset($_GET['template']))
    define('TEMPLATE', $_GET['template']);

Now I can give the template's name on URL and test it this way.
Title: Re: How to preview template?
Post by: Ruud on November 03, 2008, 02:19:34 PM
The template switcher solution here on the forum is one step further.

In your root index.php, just before the line $wb->get_page_details();, you can put this code snippet:

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

It first tests to be sure it is an existing template.
Next it is stored in a session variable, so next page will stay in the same template.
It works great.

Ruud
Title: Re: How to preview template?
Post by: weiry on December 04, 2008, 10:45:52 AM
How do you specify the new template in the url?
Title: Re: How to preview template?
Post by: Ruud on December 04, 2008, 12:53:53 PM
using the name of the template (sub)directory. (Not the template name)

so for the round template, use template=round

Ruud
Title: Re: How to preview template?
Post by: weiry on December 05, 2008, 10:51:00 AM
Thanks Rudd.

Appreciate the response. Forgive me for the questions, but is the domain name in the url www.yourdomain.com/home.php"template=round"

or how do it specify it in the url?

Cheers.
Title: Re: How to preview template?
Post by: Ruud on December 05, 2008, 11:24:45 AM
You should use:

www.yourdomain.com/pages/home.php?template=round
The ?template=round part can be added on any page in your website.

Ruud




Title: Re: How to preview template?
Post by: weiry on December 05, 2008, 11:46:40 AM
Thanks Rudd. Appreciate the answer. Exactly what I needed for a client.
Title: Re: How to preview template?
Post by: Vincent on February 17, 2009, 03:11:37 PM
Hi,

This nice snippet works fine in IE7, but doesn't in most other browsers like IE6, Firefox, Opera or Safari - at least in my case. Sure, the first page displays properly in the right template (and remains in that template even after visiting other pages of the site), but the rest of the site is shows the template I chose in the admin settings.
 
Does anyone have a clue? :|

Thanks in advance,

Vincent
Title: Re: How to preview template?
Post by: Ruud on February 17, 2009, 03:16:27 PM
It should work in all browsers, it is the server doing the "trick".

Look at your browser(s) setup(s)

It could be a caching "problem". Refresh pages with Ctrl-F5 to reload.
It could also be a cookie problem. The template is set in a session-cookie. If cookies are disabled the server will not "remember".

Ruud
Title: Re: How to preview template?
Post by: saiborg on February 17, 2009, 04:51:32 PM
Hi,

you can try the WebsiteBaker portable

http://www.websitebakers.com/pages/others/website-baker-portable.php

there you can do anything you want without any up and download

Saiborg
Title: Re: How to preview template?
Post by: Vincent on February 17, 2009, 06:30:30 PM
Thanks, Ruud, for your answer.
I noticed that it does work in all browsers on my local testing server, so I guess it is a setting on my host.
I'll contact them.
Thanks again,

Vincent

Edit: I found out that you probably need php5. My account still used php4.