Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Uranday 32 posts 53 karma points
    Apr 09, 2012 @ 07:55
    Uranday
    0

    Only showing allowed items, cant get it to work.

    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?

    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>

  • Uranday 32 posts 53 karma points
    Apr 09, 2012 @ 13:33
    Uranday
    0

    Please delete this post, I asked this question in an other topic. I cant delete it.

Please Sign in or register to post replies

Write your reply to:

Draft