#native_company# #native_desc#

PHP enabled stylesheets Page 5

By Bertrand Potier
on November 24, 2002

The CSS Stylesheet File

The PHP enabled stylesheet is nothing more that a CSS stylesheet with some
PHP code in it. What is more interesting is the benefits of that association as,
purely from a coding point of view, there’s no complexity at all.
As for the visuals.inc file, the first steps are making sure
that any variables passed on to the stylesheet.css.php are properly
retrieved. This is where we’ll encounter one of the first benefits of including
PHP code in stylesheet: implement browser based behaviors without having to
create multiple stylesheets. This will be discussed with more details in the
next sections.
To be able to use the visual parameters defined in the
visuals.inc file, this file must be included in the PHP enabled
stylesheet. This is done using the require() function, as without
this file, the stylesheet would not behave properly. Now can start the real fun
of putting some PHP in CSS (I assume you know the basics about CSS). I won’t
explain anything here; see the next sections to understand the why.


if (substr(phpversion(),0,3) != '4.1') { 



 if ( isset(
$_REQUEST['browser']) ) { 

$browser $_REQUEST['browser']; 

 } else if ( !isset(
$browser) ) { 

$browser  'ie5';    // 94% of the browsers on the web




body, h1, h2, h3, h4, h5, h6, p { 

 font-family: <?php print($VISUALS[$SkinID]['page']['font']); ?>

 font-size: <?php 





body {<?php

print('background-color: '.$VISUALS[$SkinID]['page']['background']['color'].';');



for ($i=1$i<6$i++) {

'H'.$i.' { ');

'font-size: '.($VISUALS[$SkinID]['page']['fontsize']+(6-$i)));

  print (

'font-weight: bold;');

  print (
' }');