[SOLVED] testing for https in stylesheet and update URLs

For discussion and questions related to CMS Specific templates and stylesheets (CSS), and themes. or layout issues. This is not a place for generic "I don't know CSS issues"
Post Reply
User avatar
rotezecke
Power Poster
Power Poster
Posts: 411
Joined: Fri Apr 18, 2008 9:34 pm

[SOLVED] testing for https in stylesheet and update URLs

Post 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?
Last edited by rotezecke on Thu Dec 15, 2011 3:46 am, edited 1 time in total.
Wishbone
Power Poster
Power Poster
Posts: 1368
Joined: Tue Dec 23, 2008 8:39 pm

Re: testing for https in stylesheet and update URLs

Post 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]]
User avatar
rotezecke
Power Poster
Power Poster
Posts: 411
Joined: Fri Apr 18, 2008 9:34 pm

Re: testing for https in stylesheet and update URLs

Post 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.
Wishbone
Power Poster
Power Poster
Posts: 1368
Joined: Tue Dec 23, 2008 8:39 pm

Re: testing for https in stylesheet and update URLs

Post 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.
User avatar
rotezecke
Power Poster
Power Poster
Posts: 411
Joined: Fri Apr 18, 2008 9:34 pm

re: testing for https in stylesheet and update URLs

Post by rotezecke »

Thanks a lot.
Post Reply

Return to “Layout and Design (CSS & HTML)”