Jump to content

detect if page is loaded via ssl for smarty


bartman

Recommended Posts

In your /init.php file where all the smart variables are being set, add the following line

       'is_https' => (array_key_exists('HTTPS', $_SERVER) && $_SERVER['HTTPS'] == "on"?1:0),



Then you can check in tpl files {if $is_https}

  • Like 1
Link to comment
Share on other sites

  • 1 year later...
  • 3 months later...
  • 1 year later...

Thanks, I noticed in FrontControllers.php there's $useSSL, tried {if isset($useSSL)} in header.tpl but didn't work. Could that be utilized in any way? As I tried to use 'is_https' => (array_key_exists('HTTPS', $_SERVER) && $_SERVER['HTTPS'] == "on"?1:0), but site returns an error

Link to comment
Share on other sites

okay, correct

but another question: you use it in the smarty array? it's necessary to put it to the smarty array, like i show below:

$this->context->smarty->assign(array(
  // Usefull for layout.tpl
  'is_https' => (array_key_exists('HTTPS', $_SERVER) && $_SERVER['HTTPS'] == "on"?1:0),
  'mobile_device' => $this->context->getMobileDevice(),
  ...
  ...
  ...

  • Like 1
Link to comment
Share on other sites

  • 1 year later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...