Page 1 of 1

[SOLVED] testing for https in stylesheet and update URLs

Posted: Wed Dec 14, 2011 11:00 pm
by rotezecke
{cms_stylesheet} wants absolute links to background images which I set with [[root_url]] as suggested.
I need to change this when the stylesheet is loaded via https. so i put some code up the top:

Code: Select all

[[if $smarty.server.HTTPS eq "on"]] 
[[assign var='imageURL' value='https://secure.myurl.com']]
[[else]]
[[assign var='imageURL' value='http://www.myurl.com']]
[[/if]]
(I also tried "On" and "1")
and later called background images like this

Code: Select all

background: url([[$imageURL]]/uploads/images/background/backsprite_all.png) -10px -966px no-repeat;
but the if statement always returns the http URL.
how can I change the URL based on the connection?

Re: testing for https in stylesheet and update URLs

Posted: Wed Dec 14, 2011 11:39 pm
by Wishbone
Remember that all Smarty code in stylesheets are compiled at the time of caching.. It's not dynamic.

You might want to use url(/path/to/file) instead of [[root-url]]

Re: testing for https in stylesheet and update URLs

Posted: Wed Dec 14, 2011 11:58 pm
by rotezecke
You might want to use url(/path/to/file) instead of [[root-url]]
This is what i used to do with {stylesheet} but it broke with {cms_stylesheet}. But I see what you mean.
my workaround till i have a better idea
call all background images over https which stops IE from complaining about non-secure content on a secure connection.

Re: testing for https in stylesheet and update URLs

Posted: Thu Dec 15, 2011 2:45 am
by Wishbone
No... {cms_stylesheet} broke:

url(path/to/file)

Not:

url(/path/to/file) (note the leading slash)



{stylesheet} is relative to the root_url.
{cms_stylesheet} is relative to /tmp/cache
/path/to/file is an absolute path.

re: testing for https in stylesheet and update URLs

Posted: Thu Dec 15, 2011 3:45 am
by rotezecke
Thanks a lot.