SitePoint Sponsor |
|
User Tag List
Results 1 to 5 of 5
-
Sep 17, 2007, 10:49 #1
- Join Date
- Jul 2004
- Location
- canada
- Posts
- 3,193
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Dynamic Path in background-image: url() for URL
Hi:
I have directory structure for images like
/themes/images/icon/icon_something.gif
In my CSS I specify it like
Code:background-image: url(/themes/default/images/icon/icon_confirmation.gif) ;/**/
/templates/themes/images/icon/icon_something.gif
Then it would still work.
Is there a way to change these paths dynamically in the CSS? like sending it directory path through PHP or something?
-
Sep 17, 2007, 11:06 #2
- Join Date
- Dec 2004
- Location
- Derbyshire - UK
- Posts
- 2,651
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
you should just be able to create a css file with .php extension but then serve it using type="text/css". Never tried it myself but don't see a reason why it wouldn't work
-
Sep 17, 2007, 14:52 #3
- Join Date
- Jul 2004
- Location
- canada
- Posts
- 3,193
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Never Mind. I changed and called it with parameter and it worked
HTML Code:<link href="/css/css.php?tpl_dir={$tpl_dir}" rel="stylesheet" type="text/css" media="all" />
Code:<?php header('Content-Type: Text/css'); ?> /* CSS Code Here */
-
Sep 17, 2007, 20:12 #4
- Join Date
- Jun 2007
- Location
- San Diego, CA
- Posts
- 784
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
nice. I would never have thought of putting a PHP header in a CSS file. Do you know if this is stable, or if it requires certain server settings?
Whatever you can do or dream you can, begin it.
Boldness has genius, power and magic in it. Begin it now.
Chroniclemaster1, Founder of Earth Chronicle
A Growing History of our Planet, by our Planet, for our Planet.
-
Sep 18, 2007, 07:00 #5
- Join Date
- Jul 2004
- Location
- canada
- Posts
- 3,193
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
I know it's stable. I had forgotten about it but PHPMyAdmin uses the same technique.
And you know how much PHPMyAdmin is being used.
I don't think there are any server settings which require it as PHP's header() function is always there.
Bookmarks