This has been done to death but here is my version. Works for any number of groups and any number of pages. No hard coding, just "set it and forget it"
Create your groups in FEU and on the pages that require user log in add the group name/s spelled exactly as it is in FEU groups separated by a comma "," in the extra1 field. The menu template and page template use $ccuser->memberof() and extra1 information to display the menu item and content. The function memberof() accepts a comma separated list of group names so pages can be displayed to multiple groups.
{* ****************************
MENU TEMPLATE
***************************** *}
{* 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">
{assign var="predepth" value=1}
{assign var="mminus" value=1}
{foreach from=$nodelist item=node}
{* Code added to allow multiple FEU Groups to view predetermined pages *}
{if (($ccuser->memberof($node->extra1) and $ccuser->loggedin()) or $node->extra1== '')}
{* end of new code *}
{if $node->depth > $predepth}
{repeat string='<ul class="unli">' times=$node->depth-$predepth}
{elseif $node->depth < $predepth}
{repeat string='</li><li class="separator once" style="list-style-type: none;"> </li></ul>' times=$predepth-$node->depth}
</li>
{elseif $node->index > 0}</li>
{/if}
{assign var="predepth" value=$node->depth}
{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>{$node->menutext}</span></a>
{elseif $node->type == 'sectionheader'}
><span class="sectionheader">{$node->menutext}</span></a>
{/if}
{else}
{assign var="prevdepth" value=`$node->depth-$mminus`}
{/if} {* end if member or not *}
{/foreach}
{repeat string='</li><li class="separator once" style="list-style-type: none;"> </li></ul>' times=$node->depth-1}
</li>
</ul>
<div class="clearb"></div>
</div>
{/if}
Last edited by dmgd on Fri Aug 06, 2010 11:46 am, edited 1 time in total.
{* ****************************
MENU TEMPLATE
***************************** *}
{* 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">
{assign var="predepth" value=1}
{assign var="mminus" value=1}
{foreach from=$nodelist item=node}
{* Code added to allow multiple FEU Groups to view predetermined pages *}
{if (($ccuser->memberof($node->extra1) and $ccuser->loggedin()) or $node->extra1== '')}
{* end of new code *}
{if $node->depth > $predepth}
{repeat string='<ul class="unli">' times=$node->depth-$predepth}
{elseif $node->depth < $predepth}
{repeat string='</li></ul>' times=$predepth-$node->depth}
</li>
{elseif $node->index > 0}</li>
{/if}
{assign var="predepth" value=$node->depth}
{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}">{if ($node->extra1!= '')}<div style="position:relative;"><img style="position:absolute;z-index:99;left:-14px;top:-2px;" src="custom/images/lock-icon.png"></div>{/if}<span>{$node->menutext}</span></a>
{elseif $node->type == 'sectionheader'}
>{if ($node->extra1!= '')}<div style="position:relative;"><img style="position:absolute;z-index:99;left:-14px;top:-2px;" src="custom/images/lock-icon.png"></div>{/if}<span class="sectionheader">{$node->menutext}</span></a>
{/if}
{else}
{assign var="prevdepth" value=`$node->depth-$mminus`}
{/if} {* end if member or not *}
{/foreach}
{repeat string='</li></ul>' times=$node->depth-1}
</li>
</ul>
<div class="clearb"></div>
</div>
{/if}
Greetings,
Manuel
Attachments
lock-icon.png (697 Bytes) Viewed 4259 times
Last edited by manuel on Wed Dec 29, 2010 5:50 pm, edited 1 time in total.
{* ****************************
MENU TEMPLATE
***************************** *}
{* 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">
{assign var="predepth" value=1}
{assign var="mminus" value=1}
{foreach from=$nodelist item=node}
{* Code added to allow multiple FEU Groups to view predetermined pages *}
{if (($ccuser->memberof($node->extra1) and $ccuser->loggedin()) or $node->extra1== '')}
{* end of new code *}
{if $node->depth > $predepth}
{repeat string='<ul class="unli">' times=$node->depth-$predepth}
{elseif $node->depth < $predepth}
{repeat string='</li></ul>' times=$predepth-$node->depth}
</li>
{elseif $node->index > 0}</li>
{/if}
{assign var="predepth" value=$node->depth}
{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}">{if ($node->extra1!= '')}<div style="position:relative;"><img style="position:absolute;z-index:99;left:-14px;top:-2px;" src="custom/images/lock-icon.png"></div>{/if}<span>{$node->menutext}</span></a>
{elseif $node->type == 'sectionheader'}
>{if ($node->extra1!= '')}<div style="position:relative;"><img style="position:absolute;z-index:99;left:-14px;top:-2px;" src="custom/images/lock-icon.png"></div>{/if}<span class="sectionheader">{$node->menutext}</span></a>
{/if}
{else}
{assign var="prevdepth" value=`$node->depth-$mminus`}
{/if} {* end if member or not *}
{/foreach}
{repeat string='</li></ul>' times=$node->depth-1}
</li>
</ul>
{if $ccuser->loggedin()}{else}</li></ul>{/if}
<div class="clearb"></div>
</div>
{/if}