WebsiteBaker Community Forum

WebsiteBaker Support (2.8.x) => Templates, Menus & Design => Topic started by: flamenco on July 08, 2008, 04:16:35 AM

Title: One template, many variations?
Post by: flamenco on July 08, 2008, 04:16:35 AM
Hi All,
In the past I've been asked to work mainly with one template, but have many variations. 

For instance, a template might be used throughout a site, but might use different colors on each page, maybe the background color or even just one DIV. 

Another example would be using a different banner image on each page. 

Another system I used had something called Template Variables which allowed this sort of thing very easily, along with many other types of content for each page.  It also supported inheritance, in the sense that if you picked, say, a background color for one page, all pictures underneath it would inherit that color unless you did an override for that page.

I hope that made sense.  I'm enjoying learning about show_menu and version 2 as well, but I haven't yet found a way to do what I'm describing. 

Do any of you know of ways to do something like this?  It would certainly be easier than making 12 very similar versions of the same template, for instance.

As always,
Thanks very much!
Title: Re: One template, many variations?
Post by: marathoner on July 08, 2008, 04:23:49 AM
If you simply want a way to style any given page (or the child pages of a given menu root parent) different than the default style you could use one of the two approaches in:
https://forum.WebsiteBaker.org/index.php/topic,10249.0.html (https://forum.WebsiteBaker.org/index.php/topic,10249.0.html)
Title: Re: One template, many variations?
Post by: Bramus on July 08, 2008, 09:31:41 AM
i'm doing this with a "header" on one site, http://www.marcelissen.nl This is done by an inline stylesheet in the template index.php file with an if else statement.
Code: [Select]
if (PAGE_ID == 1) { .div {background: img(header.jpg)} }
for example.
Title: Re: One template, many variations?
Post by: flamenco on July 16, 2008, 06:09:23 PM
Thanks for those ideas! 
It seems like PHP code and switch statements will be my friends.  I'm not an object-oriented genius like some of you out there, but I can easily handle this much coding.  :)

It's a bit more manual than the other system I use, but will work perfectly well, and I think this will cover most of what I need. 

To give you an idea of how the other system works, it's possible to set up, for example, and drop-down on a page which has a selection of colors, or a selection of banner images from a folder, either of which would be plugged into the CSS, and that sort of thing.  I'm thinking that this would be a large project to make something like this, though.  But maybe it will stimulate the imagination of some of our better coders here.  :)

Thanks again!