WebsiteBaker Community Forum

WebsiteBaker Support (2.8.x) => Templates, Menus & Design => Topic started by: FruitBatInShades on April 21, 2008, 12:20:24 PM

Title: TIP: Stylesheets for individual pages
Post by: FruitBatInShades on April 21, 2008, 12:20:24 PM
I am using articles on my website that need stylesheets for individual pages (demoing css techniques) but couldn't find an easy way to do this through WB. If there is a way please let me know, but if not here is my tip.

In the template I add the following to the body tag:

<body class="<?php echo ereg_replace("[^A-Za-z0-9]", "", PAGE_TITLE); ?>">


then you can access items on a page by page basis :-

body.pagename h1{}
body.pagename2 h1{}


and if you require individual stylesheets you can add the following to the header and create pagename.css in the template directory:

<link rel="stylesheet" type="text/css" media="all" href="<?php echo TEMPLATE_DIR; ?>/<?php echo ereg_replace("[^A-Za-z0-9]", "", PAGE_TITLE); ?>.css" />
Title: Re: TIP: Stylesheets for individual pages
Post by: Ruud on April 21, 2008, 05:51:36 PM
There were other posts on this forum on this issue.

A nice way is using the PAGE_ID of WB to load a different CSS on a single page.
Have a look at https://forum.WebsiteBaker.org/index.php/topic,9284.0.html (https://forum.WebsiteBaker.org/index.php/topic,9284.0.html)

It does not need understanding of regex and does the same job as your last example.

Ruud
Title: Re: TIP: Stylesheets for individual pages
Post by: DGEC on April 21, 2008, 08:05:14 PM
If someone needs a simple way of using a different stylesheet without coding, don't forget you can go to the settings for the page and change the template from "system default" to whichever one you want.