Why is <?=$this->getThemePath()?> NOT NEEDED in linked CSS?
Permalink
I original wrote my CSS straight into the header of my default.php. Then, when I put it in an external CSS file and just linked it, all the instances where I used images in the CSS with <?=$this->getThemePath()?> simply disappeared.
I remembered that I hadn't seen <?=$this->getThemePath()?> in any of the external CSS files in the Vanilla Yogurt and other themes, so I took a wild guess and deleted all instances of it from my external CSS. Sure enough, it worked.
Why is this script needed in the php files but not in external CSS files?
Just curious. Thanks.
I remembered that I hadn't seen <?=$this->getThemePath()?> in any of the external CSS files in the Vanilla Yogurt and other themes, so I took a wild guess and deleted all instances of it from my external CSS. Sure enough, it worked.
Why is this script needed in the php files but not in external CSS files?
Just curious. Thanks.
It didn't work?
It worked in the php file.
It didn't work when I added it to the external CSS file, but I could not locate that code snippet in the default yogurt theme or the one I downloaded from the marketplace (Greenfingers, if I recall correctly) and I remember wondering why these themes didn't use the snippet. I asked about it at the time, but never got a response.
Also, It should be the same path since both my external CSS and php reside in the same directory (root) and point to the same exact folder: images.
It worked in the php file.
It didn't work when I added it to the external CSS file, but I could not locate that code snippet in the default yogurt theme or the one I downloaded from the marketplace (Greenfingers, if I recall correctly) and I remember wondering why these themes didn't use the snippet. I asked about it at the time, but never got a response.
Also, It should be the same path since both my external CSS and php reside in the same directory (root) and point to the same exact folder: images.
The first time, when your CSS was in the .php file, you needed to refer to your images/ directory using the full path, thus you used getThemePath(), which is parsed by the server to return the correct full path.
In the CSS file though, you don't need the full path, thus images/image-name.ext works just fine as a relative path from the CSS to the images directory.
Also, when adding that PHP code to the .css file, it's just left AS IS and not parsed, i.e., it returns a wrong path, and that's why it didn't work.
Hope this explains it.
In the CSS file though, you don't need the full path, thus images/image-name.ext works just fine as a relative path from the CSS to the images directory.
Also, when adding that PHP code to the .css file, it's just left AS IS and not parsed, i.e., it returns a wrong path, and that's why it didn't work.
Hope this explains it.
PERFECT explanation. I'm not great with PHP, but it's stuff like this that helps me sort out the details. That makes perfect sense. Thank you very much!
Thanks okhayat,
I've used this bit of advise to include custom fonts from fontsquirrel.com in my design. I put the relative urls using php into the header code in place of where I call my external stylesheets. Works perfect.
Steve
I've used this bit of advise to include custom fonts from fontsquirrel.com in my design. I put the relative urls using php into the header code in place of where I call my external stylesheets. Works perfect.
Steve
Might want to use this instead:
Sometimes the short tags can cause server problems (in other words they are not enabled)
Thomas
<?php echo $this->getThemePath()?>
Sometimes the short tags can cause server problems (in other words they are not enabled)
Thomas
that allows regex matched identifiers to inject custom styles from the dashboard theme editor stuff.
I am not sure if that answers your question at all, but I'd recommend using firebug and seeing what path your browser is looking for your stylesheets at and see why it wasn't working :)