Page 1 of 1
Accessing value of "secure"-checkbox in templates
Posted: Thu Jun 03, 2010 3:32 pm
by Foaly*
Hi.
First of all: right board?
There's a new checkbox for (de)activating HTTPS in the options-tab of a page's edit mask. (How) can I access the value in templates? Do I have to use a UDT?
CMS Made Simple 1.7.1 "Escada"
Re: Accessing value of "secure"-checkbox in templates
Posted: Sun Jun 06, 2010 1:39 am
by NaN
Re: Accessing value of "secure"-checkbox in templates
Posted: Mon Sep 20, 2010 4:39 pm
by soundZ
Hm... that's interesting... Is there also an easy way to read read this value (mSecure) in PHP in a userdefined tag?
Thanks
soundZ
Re: Accessing value of "secure"-checkbox in templates
Posted: Mon Sep 20, 2010 5:27 pm
by NaN
Since it is a template var you can pass it as a param to an UDT:
Code: Select all
{your_udt content_obj=$content_obj}
and in your UDT you can access it
Code: Select all
$secure = $params['content_obj']->Secure();
I'm pretty sure there is another - better - way to do this but since in future CMSms releases many methods and properties of the core will be declared as private i'm not sure what function should be used here.
Don't use the mSecure variable because this will be such a private var that won't be accessible from outside of the content object context in further releases. Anyway i'm even not sure if the Secure() function will be accessible in new CMSms releases. Hope some of the devs can clearify this.
Accessing content object related properties may be useful for plugins or modules. So i hope there will be a way to access those even in new releases.
Re: Accessing value of "secure"-checkbox in templates
Posted: Mon Sep 20, 2010 11:10 pm
by soundZ
Hey NaN!
Many thanks for your quick hint! That's a nice trick and it helped me solving an annoying SSL-bug:
When switching back from an HTTPS page to an HTTP page, the HTTPS stays alive...

The following tag is a workaround for this problem. I hope in new releases of CMSms the bug will be solved so it's not important (for this case) if the Secure() method will be public or private
Here's the tag code (create a file 'function.sslbugfix.php' and copy it to 'plugins' in your CMSms installation or create a UDT:
Code: Select all
function smarty_cms_function_sslbugfix($params){
$page_secure = $params['content_obj']->Secure();
if($page_secure == 0 && isset($_SERVER['HTTPS'])){
$httpurl = 'http://'.$_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI'];
header("location: $httpurl");
die();
}
}
At the very top of your template insert:
Code: Select all
{sslbugfix content_obj=$content_obj}
That's it
I'm sure that there are much nicer and cleaner ways to do it, but I can't find them

Maybe someone can use this snippet of code, maybe not...
Thanks again for the help
soundZ
Re: Accessing value of "secure"-checkbox in templates
Posted: Tue Sep 21, 2010 12:05 am
by calguy1000
...That's a nice trick and it helped me solving an annoying SSL-bug: When switching back from an HTTPS page to an HTTP page, the HTTPS stays alive...
@soundZ You have provided ABSOLUTELY NO INFORMATION, and there have been no bug reports filed (as of this date) regarding SSL functionality in CMSMS. Additionally, the SSL functionality in recent versions of CMSMS is working to my knowledge without complaint, so before you use the word 'bug', in association with CMSMS please provide sufficient information to allow the dev team to reproduce your problem.
Re: Accessing value of "secure"-checkbox in templates
Posted: Tue Sep 21, 2010 12:46 am
by soundZ
Hey calguy1000,
sorry I thought the problem is known 'cause there are other users (in the german section of this forum) trying to solve the problem. But you're right: I haven't checked any bug lists or so

(Where would be the right place to do so?)
The problem in detail:
I've a brandnew 1.8.2 "Toliara" installation.
Some pages of the new site are marked as 'https' in the backend, others are not.
By clicking an https-marked page in the site menu the specific https-url (ssl_url) is called as root. That works very well!
But from now on ALL page links (for example in the pagemenu) on the https-page are based on the ssl_url. So you stay in ssl-mode, even if you are clicking a page NOT marked as 'https' in the backend.
I hope that's helpfull somehow...
thanks and greetings from germany
soundZ
Re: Accessing value of "secure"-checkbox in templates
Posted: Tue Sep 21, 2010 1:06 am
by jmcgin51
soundZ wrote:
I haven't checked any bug lists or so

(Where would be the right place to do so?)
http://dev.cmsmadesimple.org/projects/cmsmadesimple
Re: Accessing value of "secure"-checkbox in templates
Posted: Tue Sep 21, 2010 8:11 pm
by jomoweb
I had the same issue today, and submitted a bug. This looks like just a matter of using relative links.
If you click on the relative link from an https:// page, the https:// will stay there. I also get an error when I navigate away that the page uses items that are not secure in most browsers.
Re: Accessing value of "secure"-checkbox in templates
Posted: Wed Sep 22, 2010 2:38 am
by soundZ
Oh, I'm a little bit late... and I see, I'm not alone with the 'bug'...
As I can read, the problem will be fixed in the next release of CMSms, thanks for that in special and the great work on CMSms in general!
soundZ