For Programmers: Free Programming Magazines  


Home > Archive > PHP Programming > January 2005 > configure apache to recognize php in css files









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author configure apache to recognize php in css files
dmcconkey@yahoo.com

2005-01-28, 3:57 pm

Hi folks,

I have a website with linked CSS files controlling layout, via LINK
tags. In these linked CSS files, I need to create dynamic styles. This
is a website of articles, and for every article type in the MySQL
database, I need another style.

..article-type-0{color:red;}
..article-type-1{color:red;} etc.

I could use PHP in the HTML head to write styles, but I'm using the
media attribute of the LINK tag to control which styles go to which
output devices. Therefore, I'd like to use PHP to author a linked CSS
file.

Being an idiot, I had figured I could update my httpd.conf file (apache
2/redhat 8) and rewrite an AddType line to read:

AddType application/x-httpd-php .php .htm .html .css

It kind of worked. Almost. In fact, calling up the CSS in a browser
window showed that PHP did take over when asked and wrote my
article-type classes into the right places, using valid CSS.

However, once I did that, the web pages displayed as though no CSS file
were present.

Which tweak to httpd.conf or php.ini do I need to get PHP function in a
linked CSS file?

Thanks,
-Dan

Dani CS

2005-01-28, 3:57 pm

dmcconkey@yahoo.com wrote:
> Hi folks,
>
> I have a website with linked CSS files controlling layout, via LINK
> tags. In these linked CSS files, I need to create dynamic styles. This
> is a website of articles, and for every article type in the MySQL
> database, I need another style.
>
> .article-type-0{color:red;}
> .article-type-1{color:red;} etc.
>
> I could use PHP in the HTML head to write styles, but I'm using the
> media attribute of the LINK tag to control which styles go to which
> output devices. Therefore, I'd like to use PHP to author a linked CSS
> file.
>
> Being an idiot, I had figured I could update my httpd.conf file (apache
> 2/redhat 8) and rewrite an AddType line to read:
>
> AddType application/x-httpd-php .php .htm .html .css
>
> It kind of worked. Almost. In fact, calling up the CSS in a browser
> window showed that PHP did take over when asked and wrote my
> article-type classes into the right places, using valid CSS.
>
> However, once I did that, the web pages displayed as though no CSS file
> were present.


Maybe this works: Put

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

at the top of every .css file, so that the browser knows that it's
dealing with a CSS stylesheet.

>
> Which tweak to httpd.conf or php.ini do I need to get PHP function in a
> linked CSS file?
>
> Thanks,
> -Dan
>

dmcconkey@yahoo.com

2005-01-28, 8:56 pm


Dani CS wrote:[color=darkred]
> dmcconkey@yahoo.com wrote:
This[color=darkred]
which[color=darkred]
CSS[color=darkred]
(apache[color=darkred]
file[color=darkred]
>
> Maybe this works: Put
>
> <?php
> header("Content-Type: text/css");
> ?>
>
> at the top of every .css file, so that the browser knows that it's
> dealing with a CSS stylesheet.
>
in a[color=darkred]

That worked exceptionally well.

Much appreciated,
-Dan

Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com