I would like to hide some the menus on the navigation that a member has not access to.
For example if member1 has access to has access to everything then show every menu on the navigation.
But if member2 doesn't have access to meny2, -hide it from the navigation
How can I do this?
Here is my navigation macro code.
@inherits Umbraco.Web.Macros.PartialViewMacroPage
@{
int num = 1;
var rootNode = CurrentPage.Site();
<ul id="menu">
<li class="thehome">
<a href="@rootNode.Url" class="drop home"></a>
</li>
@foreach (var mainNode in rootNode.Children().Where("Visible"))
{
int childCount = 1;
int numChildren = mainNode.Children().Count();
<li>
<a href="@mainNode.Url" class="drop">@mainNode.Name</a>
@{
var childNodes = mainNode.Children().Where("Visible");
}
@if (childNodes.Any())
{
<div id=nav-@num class="dropdown_5columns">
<!-- Begin 2 columns container -->
<div class="col_5">
<h2>@mainNode.Name</h2>
</div>
@* note if you want ALL descendants change .Children to .Descendats*@
@foreach (var childNode in childNodes)
{
// if first node or new set of three open the div and ul @: is used to stop razor trying to
// "balance" the tags
if (childCount == 1 || (double)childCount % 3 == 1)
{
@:<div class="col-md-4">
@:<ul class="subnav">
}
<li><a href="@childNode.Url">@childNode.Name</a></li>
// close the div and list if this is either a multiple of 3 or the last one
if ((double)childCount % 3 == 0 || numChildren == childCount)
{
@:</ul>
@:</div>
}
childCount++;
}
</div>
}
</li>
num++;
}
</ul>
}
Hide navigation from non-logged in users
I would like to hide some the menus on the navigation that a member has not access to.
For example if member1 has access to has access to everything then show every menu on the navigation. But if member2 doesn't have access to meny2, -hide it from the navigation
How can I do this?
Here is my navigation macro code.
Hi Johan,
Why are you posting the same question multiple times ?
https://our.umbraco.org/forum/umbraco-7/using-umbraco-7/73461-hide-navigation-menus-for-non-logged-in-users
https://our.umbraco.org/forum/umbraco-7/using-umbraco-7/73436-hide-navigation-menus-for-non-logged-in-users
It's your third post with the same question.
Dave
is working on a reply...