WebsiteBaker Support (2.8.x) > Templates, Menus & Design

TIP: Stylesheets for individual pages

(1/1)

FruitBatInShades:
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" />

Ruud:
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

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

Ruud

DGEC:
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.

Navigation

[0] Message Index

Go to full version