Im working with Umbraco 5.1 beta. On the internet (this information is from previous versions, could not find recent documentation on it) I find that I could ask a node if the user has Access. In that way I want to build up my menu. The thing is, I cant get it to work, the HasAccess and IsProtected properties are not working. What am I doing wrong? Or does it work different in the newer versions of Umbraco? (I also tried it as method, still no result)
This is the code I'm now using:
@inherits RenderViewPage
@using Umbraco.Cms.Web;
@{
var Homepage = @DynamicModel;
while (Homepage.ContentType.Alias != "homePage")
{
Homepage = Homepage.Parent;
}
}
<ul>
<li><a href="@Homepage.Url">Home</a></li>
@foreach (var item in Homepage.Children) {
if(!item.IsProtected || (item.IsProtected && item.HasAccess)) {
if(@item.CurrentTemplate != null) {
var childName = item.Name ?? "(No name yet)";
<li><a href="@item.Url">@childName </a></li>
}
}
}
</ul>