OK, it looks like there are at least three ways to do this. I now have an original style sheet with a .css extension and copies with .php and .css.php extensions.

All three style sheets have the following code at the top:

<?
header("Content-Type: text/css");
?>

For the original style sheet, I pasted the following text into a .htaccess file:

<Files ~ "\.css$">
    ForceType application/x-httpd-php
</Files>

I haven't worked with .htaccess files before. I found one in a folder at C:/xampp/webdav/, but it sounds to me like this is something that has to be uploaded with your website, so I made a new .htaccess file with Notepad and pasted it right next to my home page.

I haven't checked to see if PHP is working with any of these strategies yet, but my regular styles are still working, with the following caveats:

A few styles were apparently knocked out of commision on the original style sheet - the one with the .css extension. Specifically, the appear to have lost the font-families assigned to them; they display as plain text, rather than Arial. One is on the main page, and the other two are on separate PHP includes. I suspect the problem might just be a bug with Dreamweaver; my style sheets act up every now and then.

Everything looks fine with the other two style sheets, but they remove the color coding from my style sheet, except for the PHP heading at the top. That's probably not a really big deal, but it would be nice to preserve the color codes.

Now I'll give all three pages a test run, after I think up a PHP function to use in them.

Thanks for all the tips!


Brian V Bonini wrote:


Just name you style sheet with a php extension.

site.css.php

and put a Content type header at the top of you style sheet.

header("Content-type: text/css" );

Then call the style sheet in one of the usual methods, link rel or
@import



On Monday, January 19, 2004, at 06:18 PM, Justin wrote:

Add this to your .htaccess file:
<Files ~ "\.css$">
    ForceType application/x-httpd-php
</Files>

Add this to the top of your CSS file:
<?

Then you can use it to do all sorts of stuff:

---
<?
header("Content-Type: text/css");
include("../inc/colours.inc");
?>
body {
    background-color: #<?=$col[1]?>;
    color: #<?=$col[1]?>;
    }

<? if(something) { ?>
p {
    font-size: 110%;
    }
<? } ?>

/*etc etc*/

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Reply via email to