#native_company# #native_desc#
#native_cta#

PHP enabled stylesheets Page 4

By Bertrand Potier
on November 24, 2002

The first step is to retrieve the values that might have been passed to the
_visuals.inc file by one of the three ways variables can be passed
from one PHP script to another:
  1. via the URL using an HTTP GET request (myfile.php?key=value);
  2. using an HTTP POST request;
  3. or including (via the include()/require() function) the
    visuals.inc file so gaining visibility on the parent script
    variables.
Since PHP 4.1, the way HTTP POST/GET request variables are handled has also
changed (we won’t discuss that here, refer to the PHP web site) and that’s the reason why the first step in the
script is, if the PHP version is not 4.1, creating and initialising a
$_REQUEST array (PHP 4.1 compliant behavior) containing the
HTTP_POST and GET arrays (used by former versions of PHP). This makes sure the
rest of the script can be developed following the latest recommendations of PHP
while still working fine on former versions (the test != '4.1' is
not fully correct as also returning true for higher versions of PHP).
The next step is making sure that whatever value passed to the
visuals.inc file in whatever way (see above) is always taken into
account. The only value that we will use is the $SkinID that is
referencing the id of the visual set to load. The code first checks if a value
is passed via HTTP POST or GET request (using the $_REQUEST
initialised sooner), if no checks that the variable is not yet defined by a
parent script (assuming visuals.inc might have been included or
required by another script) and if none of those scenarios are true, finally
give the $SkinID variable a default value equal to 0.
Finally comes the definition of the visuals parameters and for this example I
limited their number to four: font, font size, font unit and page background
color. I recommend that, when naming the first dimension of the
$VISUALS array, you link it to structural elements of your web
page. Let’s imagine that you define visual parameter for the footer section of
your web then declare a $VISUALS[0]['footer'] dimension.
The visuals.inc file is now ready; let’s move on to the
stylesheet.

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