Page 2 of 2

[SOLVED] Re: Help with Custom Content

Posted: Tue Jun 02, 2009 7:03 am
by sing2trees
dendle wrote: Hi All,

I have just mocked up this thread in my CMSMS Test Installation and produced the same error.  As a test I put the if then else code within the body tags of the document template rather than wrapping around the whole document.  This technique works very well, first time every time.

A quick note, I use both the $ccuser-->loggedin() and the $ccuser->memberof(GROUPNAME)  conditions as $ccuser seems to return true even if no-one is logged in (it seems to treat no-one logged in as an anonymous user).  Please let me know if this understanding is not correct.  As a note, without using $ccuser group to check the user the page will let anyone in (authenticated or otherwise).  

Having said that this technique does work for me, and I am interested in others thoughts and if it helps......
I am running CMSMS 1.5.4; PHP 5.2.8; MySQL 5.0.77-community and Apache 2.2.11 running under a linux kernel 2.6.18-19.el5
IE:

Code: Select all

<__html>
</__body>
{if $ccuser-->loggedin() && $ccuser->memberof(Clients)}

....content of page if user is logged in.
{cms_module module='FrontEndUsers' form='logout}
{else}
{redirect_page page='client'}
{/if}
<__body>
</__html>
Final note, do not use this template for the login page (it will cause a recursive loop).  My solution was to implement the if then else statement directly in the code of the login page itself, it looks something like this:

Code: Select all

{if $ccuser->loggedin() && $ccuser->memberof(Clients)}
{redirect_page page='client-home'}
{else}
Please use the form below to login<br />
{cms_module module='FrontEndUsers' form='login'}
{/if}
This works a treat! Many thanks!!!

Re: Help with Custom Content

Posted: Tue Jun 02, 2009 7:21 am
by Jeff
Dendle: You are not correct about being logged in as anonymous, I believe it is always returning true because you have $ccuser-->loggedin() it should be $ccuser->loggedin()

Re: Help with Custom Content

Posted: Tue Jun 02, 2009 11:04 am
by dendle
Many thanks you are correct, my bad on the code.  It should be -> not --> as I have indicated......