Long answer: using a bit of black magic you can add variables to your CSS Files by asking Apache to redirect any stylesheet to a special PHP script which will open the stylesheet, find and replace any user-defined variables, then serve up the parsed content will be displayed as pure CSS.

<?php
$domain = "mywebsite1";
?>
// then elsewhere, building up some html/JS output
$('#dvBackGround').css('background','path/to/image/<?php echo $domain; ?>.jpg');
// back on with the page

popartns
—
2012-09-19T12:39:44Z —
#4

You cloud create additional file called custom.css and place it in a folder relative to your PHP $domain var path. Inside it, you can put your CSS and always be sure what path to use in url(), like in background CSS property.

vinpkl
—
2012-09-19T15:54:43Z —
#5

thank pullo

thats a long article. i will spend time learning it

vineet

cpradio
—
2012-09-19T16:00:15Z —
#6

Pullo said:

Short answer: can't be done.

I might be wrong, but I would think so long as you return a mime type header of text/css the browser will render it as a CSS instruction.

I used the above method for developing but unfortunately www.validation.w3.org does not recognise the .php extension.

To get round this I view the source using the FireFox browser then click on the stylesheet.PHP file and the source appears in another window. Source then copied, pasted and saved to stylesheet.css

I did not know that. That is good information to have. I'm sure there are ways that can be worked around it (if need be), but it is something to keep in mind that you will have to do a workaround to validate your stylesheets.

Markdidj
—
2012-09-20T10:08:30Z —
#14

Why are you using the domain variable? Start the url with a forward slash and it uses the root anyway.