• twitter image
  • facebook image
  • youtube image
  • linkedin image
Language: CMS Made Simple Czech CMS Made Simple France CMS Made Simple Spain CMS Made Simple Hungary CMS Made Simple Russia CMS Made Simple Netherlands

All times are UTC




Post new topic Reply to topic  [ 4 posts ] 
Author Message
 Post subject: Showing Content and Menus items to Mulit Groups
PostPosted: Thu Aug 05, 2010 10:09 pm 
Offline
Forum Members
Forum Members

Joined: Tue Jun 06, 2006 1:10 pm
Posts: 110
Location: TX
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.

Code:
{* Template code for the content *}
          {page_attr key='extra1' assign='extra1'}
          {if ($ccuser->memberof($extra1) and $ccuser->loggedin()) or $extra1 == ''}
            {content}
          {else}
               <p>Please login first:</p>
               {cms_module module="FrontEndUsers"  nocaptcha="1"}
          {/if}


Code:
{* ****************************
   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}

_________________
Mark


Last edited by dmgd on Fri Aug 06, 2010 11:46 am, edited 1 time in total.

Top
 Profile  
 
 Post subject: Re: Showing Content and Menus items to Mulit Groups
PostPosted: Wed Dec 29, 2010 4:29 pm 
Offline
Dev Team Member
Dev Team Member
User avatar

Joined: Fri Nov 30, 2007 9:15 am
Posts: 329
Hi Dmgd,

Thanks for sharing this, it's working perfectly!

Greetings,
Manuel

_________________
Do you like your open source cms? Buy from the CMSMS partners || Donate
(or at least share some knowledge :D >> See some of my stuff )


Top
 Profile  
 
 Post subject: Re: Showing Content and Menus items to Mulit Groups
PostPosted: Wed Dec 29, 2010 5:47 pm 
Offline
Dev Team Member
Dev Team Member
User avatar

Joined: Fri Nov 30, 2007 9:15 am
Posts: 329
Hi Dmgd,

In the code below, i show some small lock icon next to the members only pages in the menu. (and I removed the "separator once" items)

Code:
{* ****************************
   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
lock-icon.png [ 697 Bytes | Viewed 1805 times ]

_________________
Do you like your open source cms? Buy from the CMSMS partners || Donate
(or at least share some knowledge :D >> See some of my stuff )


Last edited by manuel on Wed Dec 29, 2010 5:50 pm, edited 1 time in total.
Top
 Profile  
 
 Post subject: Re: Showing Content and Menus items to Mulit Groups
PostPosted: Thu Mar 24, 2011 3:09 pm 
Offline
Dev Team Member
Dev Team Member
User avatar

Joined: Fri Nov 30, 2007 9:15 am
Posts: 329
UPDATE: I was having some trouble with a multi language site showing a broken menu when the user wasn't logged in...

After looking in the code it appeared there where some tags missing from the menu.

I had to add {if $ccuser->loggedin()}{else}</li></ul>{/if} to the end of the template to fix it...

Code:
{* ****************************
   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}


Greetings,
Manuel


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Arvixe - A CMSMS Partner