Jump to content

trying to pickup on SSL active to post image.


durangod

Recommended Posts

Hi,

 

i posted this in the footer tpl file but its not picking up the https value to show the image, any ideas?

 

{if !empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off' || $_SERVER['SERVER_PORT'] == 443}
<center>
<img src="/images/ssl_seal.gif" border="0" alt="SSL Seal" />
</center>
{/if}

 

it looks like there is no value for any of those.. mmmmm

 

thanks

Edited by durangod
Link to comment
Share on other sites

Here is a JS attempt but still does not work

 

<div id="sslbadge" style="display: none;">
   <img src="/images/ssl_seal.gif" border="0" alt="SSL Seal" />
</div>
<script type="text/javascript">
if ("https:" === window.location.protocol) 
{
document.getElementById('sslbadge').style.display = 'block';
}
</script>


Link to comment
Share on other sites

here is what finally worked and this is in footer tpl

 

i checked the source and in the source it was only showing this much.

 

<script type="text/javascript">
if(location.protocol === "https:") 
</script>

 

so i was like ok no wonder its not doing anything because its not being told what to do. So then i realized (and this is a guess on my part) that since this is inside a smarty tpl file and smarty uses {} for php operations, then it probably confused the portion inside the js brackets for php.

 

So i removed the brackets which i think are just for decoration anyway, and whallaaa there it was.

 

i did try to use margin:0px auto to center and stay away from the center tag but nothing i tried css wise worked so i juse went back to the center tag.

 

here is the final code..

 

<!-- added to only show seal on ssl pages -->
<div id="sslbadge" style="display:none;">
   <center>
   <img src="/images/ssl_seal.gif" border="0" alt="SSL Seal" />
   </center>  
</div>

<script type="text/javascript">
if(location.protocol === "https:") 
document.getElementById('sslbadge').style.display = '';
</script>
<!-- end add -->

Edited by durangod
Link to comment
Share on other sites

  • 3 weeks later...

The brackets {} are there so it knows what to do if it equals it. The reason it's working is because you only have 1 line of code after the if statement so really the brackets are not needed.

 

Here is why it would not work with the brackets....

 

When using a template file .tpl you have to let the system know what not to change. So things you want to work just as they are, such as java, you put this around it..

 

{literal}

 

{/literal}

 

So it would have worked had you done it this way...

 

{literal}

<script type="text/javascript">

if(location.protocol === "https:") {

document.getElementById('sslbadge').style.display = '';

}

</script>

{/literal}

 

However, the way you have it is just fine :) Great job!

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use & Guidelines and understand your posts will initially be pre-moderated