Gunnar Lium wrote:
I'm experimenting with creating a dynamic CSS-file. What I have done is
to send CSS-files trough a PHP-parser, to enable the use of variables
(Apache2, PHP5). This is done by adding "AddType
application/x-httpd-php .css" to a .htaccess-file in the same directory
as the CSS-file. The problem is that this at the same time sets the
mimetype to text/html, which results in Firefox (winXP) refusing to
load the CSS.
What I basically want to do is to allow parsing of the file through
PHP, but still send the file as text/css to the client.
This is what I am doing at www.gutenberg.org. No need to tinker with
.htaccess files.
Warning: this makes the served CSS non-cacheable. It will generate more
load to your server than a static css.
<?php
// css-server.php
// usage: <link rel="stylesheet" href="css-server.php" type="text/css">
header ("Content-type: text/css");
if ($_SERVER['SERVER_PROTOCOL'] == 'HTTP/1.0') {
// this makes HTTP/1.0 shared caches ignore this object
header ("Expires: Sun, 03 Oct 2004 12:00:00 GMT");
header ("Cache-Control: no-cache");
header ("Pragma: no-cache");
} else {
// this makes HTTP/1.1 private caches cache this object
header ("Cache-Control: private, max-age=86400");
}
$skin = url_of_appropriate_css_file ();
$contents = "@import url(\"$skin\");\n";
header ("Content-Length: " . strlen ($contents));
echo $contents;
?>
--
Marcello Perathoner
[EMAIL PROTECTED]
______________________________________________________________________
css-discuss [EMAIL PROTECTED]
http://www.css-discuss.org/mailman/listinfo/css-d
List wiki/FAQ -- http://css-discuss.incutio.com/
Supported by evolt.org -- http://www.evolt.org/help_support_evolt/