Page 1 of 1

[SOLVED] Hiding menu for not logged in people

Posted: Mon May 07, 2012 1:07 am
by hanslammerts
Hi,

I'm trying to hide menu content (and thus the restricted pages) for people that have not logged in.
I'm running CMSMS 1.10.3.
Have found an excellent document by Robert, dating form 2009, that describes this exact feature. I am unsure, however, if thsi pdf is still valid for later versions of CMSMS.

I followed the PDF up to the point where it comes to hiding menu items for people that are not logged in. Everything else works nicely. If you're not logged in, and you click the menu item the was not supposed tobe visible, you get redirected to the login page.

Maybe my problem just lies in the fact that I used a different template, namely BluecCity, and I do not understand where to incorporate the lines of code to check whether someone's logged in or not.

I copied the BlueCity menu template, and named it bluecity-restricted.
Below is the content :

Code: Select all

{* CSS classes used in this template:
#menuwrapper - The id for the <div> that the menu is wrapped in. Sets the width, background etc. for the menu.
#primary-nav - The id for the <ul>
.menuparent - The class for each <li> that has children.
.menuactive - The class for each <li> that is active or is a parent (on any level) of a child that is active. *}
{if $count > 0}
<div id="menuwrapper">
<ul id="primary-nav">
{foreach from=$nodelist item=node}
{if $node->depth > $node->prevdepth}
{repeat string='<ul class="unli">' times=$node->depth-$node->prevdepth}
{elseif $node->depth < $node->prevdepth}
{repeat string='</li></ul>' times=$node->prevdepth-$node->depth}
</li>
{elseif $node->index > 0}</li>
{/if}
{if $node->parent == true or ($node->current == true and $node->haschildren == true)}
<li class="menuactive menuparent">
<a class="menuactive menuparent" {elseif $node->current == true}
<li class="menuactive">
<a class="menuactive" {elseif $node->haschildren == true}
<li class="menuparent">
<a class="menuparent" {elseif $node->type == 'sectionheader' and $node->haschildren == true}
<li class="sectionheader"><span class="sectionheader">{$node->menutext}</span>{elseif $node->type == 'separator'}
<li style="list-style-type: none;"> <hr class="menu_separator" />{else}
<li>
<a {/if}
{if $node->type != 'sectionheader' and $node->type != 'separator'}
{if $node->target}target="{$node->target}" {/if}
href="{$node->url}"><span {if $node->hierarchy=="1"}class="first"{/if}>{$node->menutext}</span></a>
{elseif $node->type == 'sectionheader'}
><span class="sectionheader">{$node->menutext}</span></a>
{/if}
{/foreach}
{repeat string='</li></ul>' times=$node->depth-1}
</li>
</ul>
<div class="clearb"></div>
</div>
{/if}
I tried putting the lines that are mentioned in the document on page 25 into this template in several locations, but the result invariably is that I still see the menu item that is not to be shown until after login.

Could anyone please tell me if this template is useable for this technique anyhow, and if yes, where to place the if statement ?

Did search the forum, but was unable to get to a solution.

Thanks,

Hans

Re: Hiding menu for not logged in people

Posted: Mon May 07, 2012 6:28 am
by timdebuurman
Hi,

I noticed that if I set the content type of a page to "Protected Content" , the page automatic disappeared from the menu.

Re: Hiding menu for not logged in people

Posted: Mon May 07, 2012 10:38 am
by hanslammerts
Hi Tim,

Thanks for the swift reply.
Is it that simple ? Will try this immediately when I come home.
I'm guessing that once you're logged in, the menu item appears ?
So no extra code necessary in menu templates, or wherever ?

Bedankt,

Hans

P.S.
Verre vrienden zijn ook leuk. Kun je fijn op vakantie....

Re: Hiding menu for not logged in people

Posted: Mon May 07, 2012 1:05 pm
by timdebuurman
Hans,

Indeed, after I logged in, the menuitem directly appeared.

Only one thing.

I'm using Advanced Conent for my pages and the type "Protected Content" doen not have the features that the "Advanced Content" has.

But that's something for another topic...

Tim

Re: Hiding menu for not logged in people

Posted: Mon May 07, 2012 11:28 pm
by hanslammerts
Hi Tim,

Checked it out, and it does work.
Makes me feel a bit silly, because it will probably be in the up-to-date docs that I did not read since I thought the PDF by Calguy1000 was the way to go. It still is partially, of course, but this makes life so much easier.

Thanks again.

Hans