Welcome Guest, Not a member yet? Register   Sign In
Using Dynamic CSS
#11

[eluser]llbbl[/eluser]
[quote author="thepyromaniac" date="1191821062"]This is a problem I was contemplating the other day. I use a modular asset managing helper (functions that calls pics, css, etc and allow for awesome organisation) and I came accross the problem that while I have managed to completly solve my "how to point to images" within PHP files, I cannot do the same in CSS.

So, if i have <?=image_asset('not_porn.jpg');?> in my PHP files, whats the best way to go about a similar thing in CSS? I was considering some CRAZY solution for using a CSS controller for making partial css views, but thats just retarded. Anyone else have a better plan?[/quote]

Just how you would do it in PHP, with the variable.


Code:
// css style sheet called style.php

[url=http://www.w3schools.com/css/css_background.asp]body[/url]{
background-image:  url('<?=$img_url; ?>');
}

then the html + php in your test.php file.

Code:
<?php

if ($something){
    $img_url = "http://example.com/image1.jpg";
}else{
    $img_url = "http://example.com/image2.jpg";
}

?>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
   "http://www.w3.org/TR/html4/loose.dtd">

&lt;html lang="en"&gt;
&lt;head&gt;
    &lt;meta http-equiv="Content-Type" content="text/html; charset=utf-8"&gt;
    &lt;title&gt;untitled&lt;/title&gt;
    &lt;meta name="generator" content="TextMate http://macromates.com/"&gt;
    &lt;link href="style.php" rel="stylesheet" type="text/css"&gt;
    &lt;!-- Date: 2007-10-07 --&gt;
&lt;/head&gt;
&lt;body&gt;

&lt;/body&gt;
&lt;/html&gt;


Messages In This Thread
Using Dynamic CSS - by El Forum - 10-06-2007, 08:17 PM
Using Dynamic CSS - by El Forum - 10-06-2007, 09:00 PM
Using Dynamic CSS - by El Forum - 10-06-2007, 11:27 PM
Using Dynamic CSS - by El Forum - 10-07-2007, 07:46 AM
Using Dynamic CSS - by El Forum - 10-07-2007, 12:09 PM
Using Dynamic CSS - by El Forum - 10-07-2007, 03:37 PM
Using Dynamic CSS - by El Forum - 10-07-2007, 04:42 PM
Using Dynamic CSS - by El Forum - 10-07-2007, 05:21 PM
Using Dynamic CSS - by El Forum - 10-07-2007, 06:24 PM
Using Dynamic CSS - by El Forum - 10-07-2007, 06:27 PM
Using Dynamic CSS - by El Forum - 10-07-2007, 08:34 PM
Using Dynamic CSS - by El Forum - 10-08-2007, 05:13 AM
Using Dynamic CSS - by El Forum - 10-08-2007, 07:22 AM
Using Dynamic CSS - by El Forum - 10-08-2007, 07:41 AM
Using Dynamic CSS - by El Forum - 10-08-2007, 08:52 AM
Using Dynamic CSS - by El Forum - 10-08-2007, 09:00 AM
Using Dynamic CSS - by El Forum - 10-08-2007, 09:12 AM
Using Dynamic CSS - by El Forum - 10-08-2007, 09:29 AM



Theme © iAndrew 2016 - Forum software by © MyBB