bartman Posted April 20, 2010 Share Posted April 20, 2010 is there anyway i can tell if a page has been called via ssl in a .tpl file, looking to use something like {if ssl} do something {else} do something else {/if} is this possibleregardsChris 1 Link to comment Share on other sites More sharing options...
tomerg3 Posted April 22, 2010 Share Posted April 22, 2010 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} 1 Link to comment Share on other sites More sharing options...
lemnisk8 Posted December 8, 2011 Share Posted December 8, 2011 Thanks a lot... was looking for it for long Link to comment Share on other sites More sharing options...
Jabouty Posted March 30, 2012 Share Posted March 30, 2012 Not to necro or anything, but wanted to say that this particular snippet just saved my backside. Thank you! Link to comment Share on other sites More sharing options...
projects Posted July 16, 2013 Share Posted July 16, 2013 Thanks for this solution, how would one accomplish this in 1.5? As init.php is using controllers Link to comment Share on other sites More sharing options...
vekia Posted July 16, 2013 Share Posted July 16, 2013 Thanks for this solution, how would one accomplish this in 1.5? As init.php is using controllers where you want to use this variable? this is most important question in this case 1 Link to comment Share on other sites More sharing options...
projects Posted July 16, 2013 Share Posted July 16, 2013 Trying to hide a javascript in in one of my tpl files as it's causing issues with SSL enabled. Was using {if pagename}{else}{/if} but not efficient as I'd have to include all pages using SSL in the tag. Link to comment Share on other sites More sharing options...
vekia Posted July 16, 2013 Share Posted July 16, 2013 okay you can define it in the front controller check classes/controller/FrontController.php file Link to comment Share on other sites More sharing options...
projects Posted July 16, 2013 Share Posted July 16, 2013 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 More sharing options...
vekia Posted July 16, 2013 Share Posted July 16, 2013 where you use this code? in what function? Link to comment Share on other sites More sharing options...
projects Posted July 16, 2013 Share Posted July 16, 2013 (edited) Tried using 'is_https' => (array_key_exists('HTTPS', $_SERVER) && $_SERVER['HTTPS'] == "on"?1:0), in public function init()[/size] [size=4] Edited July 16, 2013 by projects (see edit history) Link to comment Share on other sites More sharing options...
vekia Posted July 16, 2013 Share Posted July 16, 2013 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(), ... ... ... 1 Link to comment Share on other sites More sharing options...
projects Posted July 16, 2013 Share Posted July 16, 2013 Ahhh gotcha thanks a lot! I was putting it in right after the public function init() Link to comment Share on other sites More sharing options...
vekia Posted July 16, 2013 Share Posted July 16, 2013 you're welcome i'm glad that i could help now we have solution for 1.5 also thanks! 1 Link to comment Share on other sites More sharing options...
hatak Posted October 17, 2014 Share Posted October 17, 2014 in ps1.6 it not worked for me i've used //ssl code for tpls $al1 = $useSSL; $this->context->smarty->assign('is_https', $al1); //end of that code in init function of FrontControler Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now