Tutorial :How do you solve the problems of URLs in a CSS file when using ZF?


I am using background images in my css, which, obviously, requires writing URLs in the css file.
So, while the relative path might be the same, the base URL will be different between development and production.
So, is there a better solution than:
1. changing it each time manually
2. using resources on the cloud with full URL
3. making the CSS files parsed as PHP, and using some
code in it (and then I have to fix the problem with caching).


CSS URLs are parsed from the directory containing the CSS. Meaning it won't change. So all you should have to do is give them paths relative to the CSS Directory and you should be good.


div {      background: transparent url(../images/background.jpg) no-repeat;  }  


i asked that question b4 in another forum


the solution was to use a view helper baseUrl

<img src="<?php echo $this->baseUrl();?>/images/foo.gif">   


I use the symfony framework, and I've found that parsing it as PHP works best. It's the most dynamic, and if you ever need anything more than just a URL, you can with the PHP.


One obvious answer to this is use the purest form of absolute URL, a filename, by putting all your CSS images into the CSS folder. That's used a lot. You gain simplicity in your URLs, you can now move or rename the CSS folder itself without hassle, and your stylesheet gets that little bit smaller.

Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Next Post »