#native_company# #native_desc#
#native_cta#

PHP enabled stylesheets Page 2

By Bertrand Potier
on November 24, 2002

Principles

The main principle of this solution is that all the involved components,
including the stylesheet, are PHP components that will be interpreted by the web
server before being offered to the user. All the involved components will
therefore be named with a .php file extension but the visual
configuration one that will use a .inc extension (include PHP
file).
Illustrating this article requires the creation of three files:
  1. The CSS stylesheet stylesheet.css.php file that is a normal
    CSS stylesheet but including some PHP code. For that reason, and although the
    .css extension is kept, the file is named as a PHP file. For some
    reason that I don’t know yet, this type of filename containing two dots can
    cause some problems on some operating systems. If so, simply change the
    filename from stylesheet.css.php to
    stylesheetcss.php.
  2. The visual configuration visuals.inc file that will contain
    the visual configuration parameters as an array of key-value pairs (similar to
    the WINDOWS INI file way). This file is being included in the CSS stylesheet
    in order to make the visual configuration parameters available to the
    stylesheet.
  3. The index index.php file that is our test file and will
    mainly contain HTML code using the styles defined in the stylesheet.
To avoid any confusion, those three files are assumed to be stored in the
same directory. The location of this directory is not important as long as it is
located somewhere under the root of your web server. Let’s move on to the
definition of the visuals.inc file.

1
|
2
|
3
|
4
|
5
|
6
|
7
|
8
|
9
|