inserting php into css to show url of background image

liunx

Guest
how would I do this?

for one, I want the css to be linked from another page in another directory, which I already have going on, but each page that links to this css will often have different background images. I tried linking to a css, and add to the body style like this...

(quick note: At the beginning of every page, I have a quick php script that tells the page any universal directories and by only changing one variable it makes it so I can link to any of these often linked files in these directories with just a quick php print of the variable.)

<link href=http://www.webdeveloper.com/forum/archive/index.php/"<?php print $reSrc_CssDir ?>/basic.css" rel="stylesheet" type="text/css">
<style type="text/css">
<!--
body {
background-image: url(_RESOURCES/_BACKGROUNDS/cold%20white_withshadow.jpg);
}
-->
</style>

But the thing is, I don't want to type the directory for every single page (_RESOURCES/_BACKGROUNDS/), I want that inserted with php, and both when I put the background-image style in this page to add it to the linked css and when I try putting the background-image style directly in the linked css file, it doesn't seem like I can print a php variable of the URL into the background-image style.

ie:

this is the linked css file in another directory...
body,td,th {
font-family: Century Gothic;
font-size: medium;
color: #000000;
}
body {
background-color: #666666;
background-image: url(<?php print $reSrc_BgDir ?>cold%20white_withshadow.jpg);
margin-left: 50px;
margin-right: 50px;
background-attachment: fixed;
}
a {
font-family: Century Gothic;
color: #91B2DB;

etc. etc.I think you need to put that line on your page rather than in the external css file. I think that the php you've put in the external file won't be read by the server as it doesn't have a php extension.

As you can see, I'm not 100% sure I've understood you correctly or if this is the right answer, but I thought it was worth giving you what I'm thinking. I know you can use php with css, but not like that.
 
Back
Top