PHPBuilder - PHP enabled stylesheets Page 8



RSS Twitter
Articles Html

PHP enabled stylesheets - Page 8

by: Bertrand Potier
|
November 24, 2002

Warning: Be careful, each browser on each platform reacts differently to those instructions and tests are required to make sure that your Javascript will behave as expected. Even the browser detection scripts on website such as Javascript.com cannot be considered as working correctly in all situations.
An easy way to make the $platform variable to the PHP code is to recall the index file with some parameters. This is almost invisible for the visitor but do not forget to include a $detect variable (initialised to true if not set) to avoid to enter a loop where the index file is replaced and replaced again. As soon as the parameter (here platform) is detected, the $detect variable is set to false.
The variable $platform is now available to the index file and therefore to the stylesheet. You can test it using a switch() { case: ; } block and, in our example, increase the font size by 2 in case a Mac based platform is detected (extracted from stylesheet.css.php):

<?php
body
h1h2h3h4h5h6
 
font-size:<?php 
 
switch($platform) {
  case 
'mac';
   print(
$VISUALS[$SkinID]['page']['fontsize'] + 2;
   break;
  default:
   print(
$VISUALS[$SkinID]['page']['fontsize'];
   break;
  } 
 print( 
$VISUALS[$SkinID]['page']['fontunit'] ); ?>;
 ?>;
}
?>
The value of this increment should depend on the font unit that you use (px, pt, em, etc.). This increment could also be declared as a new visual parameter to be included in your visual configuration file as:

<?php
$VISUALS
[0]['page']['fontsize']['increment']
?>
(extracted from visuals.inc).

« Previous Page
1
|
2
|
3
|
4
|
5
|
6
|
7
|
8
|
9
|
10
Next Page »

Comment and Contribute

Your comment has been submitted and is pending approval.

Author:
Bertrand Potier

Comment:



Comment:

(Maximum characters: 1200). You have characters left.