phpcssvariablessmartysmarty2

How to access smarty variable in css URL attribute?


I've used following line in my code of CSS into smarty template file :

background: url('{$site_url}/new_logo.jpg) no-repeat;

But I'm not able to locate this image. I checked in firebug console as well as in browser. Image not found message is showing.

The {$site_url} variable actually contains the path but I'm not able to access it. Can someone please help me in accessing this variable in above code?

Even I tried it with enclosing the above entire path into double quotes instead of single quotes, tried with removing the quotes but no success.

Thanks in advance.


Solution

  • You miss ending quote in this declaration. It should be:

    background: url('{$site_url}/new_logo.jpg') no-repeat;
    

    If it doesn't work look at your page source and make sure the image exist in this location or change value of your $site_url variable.