Author Topic: How to preview template?  (Read 8191 times)

Ale

  • Guest
How to preview template?
« 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.

Offline Stefek

  • Posts: 6177
  • Gender: Male
  • ("ړ)
Re: How to preview template?
« Reply #1 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
"Gemeinsam schafft man mehr."

gemeinsam
1. mehreren Personen oder Dingen in gleicher Weise gehörend, eigen
2. in Gemeinschaft [unternommen, zu bewältigen]; zusammen, miteinander
#Duden

Ale

  • Guest
Re: How to preview template?
« Reply #2 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.

Offline Ruud

  • Posts: 3660
  • Gender: Male
  • Do not use PM for help! Please use the forum!
    • Dev4Me - Professional WebsiteBaker Development
Re: How to preview template?
« Reply #3 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


Offline Stefek

  • Posts: 6177
  • Gender: Male
  • ("ړ)
Re: How to preview template?
« Reply #4 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

"Gemeinsam schafft man mehr."

gemeinsam
1. mehreren Personen oder Dingen in gleicher Weise gehörend, eigen
2. in Gemeinschaft [unternommen, zu bewältigen]; zusammen, miteinander
#Duden

Offline Ruud

  • Posts: 3660
  • Gender: Male
  • Do not use PM for help! Please use the forum!
    • Dev4Me - Professional WebsiteBaker Development
Re: How to preview template?
« Reply #5 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

Ale

  • Guest
Re: How to preview template?
« Reply #6 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.

Offline Ruud

  • Posts: 3660
  • Gender: Male
  • Do not use PM for help! Please use the forum!
    • Dev4Me - Professional WebsiteBaker Development
Re: How to preview template?
« Reply #7 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

Offline weiry

  • Posts: 92
Re: How to preview template?
« Reply #8 on: December 04, 2008, 10:45:52 AM »
How do you specify the new template in the url?
« Last Edit: December 04, 2008, 11:26:11 AM by weiry »

Offline Ruud

  • Posts: 3660
  • Gender: Male
  • Do not use PM for help! Please use the forum!
    • Dev4Me - Professional WebsiteBaker Development
Re: How to preview template?
« Reply #9 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

Offline weiry

  • Posts: 92
Re: How to preview template?
« Reply #10 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.

Offline Ruud

  • Posts: 3660
  • Gender: Male
  • Do not use PM for help! Please use the forum!
    • Dev4Me - Professional WebsiteBaker Development
Re: How to preview template?
« Reply #11 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





Offline weiry

  • Posts: 92
Re: How to preview template?
« Reply #12 on: December 05, 2008, 11:46:40 AM »
Thanks Rudd. Appreciate the answer. Exactly what I needed for a client.

Offline Vincent

  • Posts: 376
  • Gender: Male
    • websites voor ondernemers
Re: How to preview template?
« Reply #13 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

Offline Ruud

  • Posts: 3660
  • Gender: Male
  • Do not use PM for help! Please use the forum!
    • Dev4Me - Professional WebsiteBaker Development
Re: How to preview template?
« Reply #14 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

Offline saiborg

  • Posts: 101
    • microott.de
Re: How to preview template?
« Reply #15 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
schaut doch mal vorbei

http://www.microott.de

Offline Vincent

  • Posts: 376
  • Gender: Male
    • websites voor ondernemers
Re: How to preview template?
« Reply #16 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.
« Last Edit: February 17, 2009, 07:29:08 PM by Vincent »

 

postern-length