Copied to clipboard

Flag this post as spam?

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


  • Tom 713 posts 952 karma points
    Nov 03, 2011 @ 07:43
    Tom
    0

    AncestorOrSelf in 4.7.1

    Hi all,

    using 4.7 I was running the following:

     

    in 4.7.1 something seems to be mucked up with the implementation of AncestorOrSelf(int Level) because it's returning null for AncestorOrSelf(2) in exactly the same macro no structures have been changed...

    can someone explain please..

     

     <umbraco:Macro runat="server" language="cshtml">
                  <div class="images-and-links">
                    @if (Model.image is int)
                    {
                      <img src="@Model.Media("image").umbracoFile" alt="" />
                    }
                    @if (@Model.AncestorOrSelf(2).Children.Any())
                    {
                      <div class="links">
                        @if (Model.AncestorOrSelf(2).Id != Model.Id)
                        {
                          <href="@Model.AncestorOrSelf(2).Url" class="parent">
                            @(string.IsNullOrEmpty(@Model.AncestorOrSelf(2).title.ToString()) ? @Model.AncestorOrSelf(2).Name : @Model.AncestorOrSelf(2).title)
                          </a>
                        }
                        <ul>
                        @foreach (var childPage in @Model.AncestorOrSelf(2).Children)
                        {
                          if (childPage.HasAccess && childPage.NodeTypeAlias != "LoginPage")
                          {
                            <li>
                              @if (Model.Id != childPage.Id)
                              {
                                <href="@childPage.Url">
                                  @(string.IsNullOrEmpty(childPage.title.ToString()) ? childPage.Name : childPage.title)
                                </a>
                              }
                              else
                              {
                                @(string.IsNullOrEmpty(childPage.title.ToString()) ? childPage.Name : childPage.title)
                              }
                            </li>
                          }
                        }
                        </ul>
                      </div>
                    }
                  </div>
                </umbraco:Macro>
  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies