Copied to clipboard

Flag this post as spam?

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


  • Jon R. Humphrey 164 posts 455 karma points c-trib
    Jun 29, 2015 @ 14:26
    Jon R. Humphrey
    0

    looping through the forest... uSkinned Source v1 & traversing nodes issue

    I'm using the uSkinned Source v1 starter kit and have nested resource sections below a general page clone called "Resources":

    • Resources (USNResourcePage)
      • Page Components
        • Main Resources (USNResourcesSectionAN)
          • resource.pdf (USNResource)[media]
      • ChildResourcePage(USNResourcePage)
        • Page Components
          • Child Resources1(USNResourcesSectionAN)
            • resource1A.pdf (USNResource)[media]
          • Child Resources2(USNResourcesSectionAN)
            • resource2A.pdf (USNResource)[media]
            • resource2B.pdf (USNResource)[media]
            • resource2C.pdf (USNResource)[media]
          • Child Resources3(USNResourcesSectionAN)
            • resource3A.pdf (USNResource)[media]
            • resource3B.pdf (USNResource)[media]

    I'm trying to loop through each section and list it's children accordingly alongside it's title if needed but no matter what I try I can't hook into the correct node to cascade down? I know it's my loop that's the issue but need another set of eyes to show me where I'm wrong!

    @inherits Umbraco.Web.Mvc.UmbracoViewPage<IPublishedContent>
    
    @using USN.BusinessLogic
    @using RJP.MultiUrlPicker.Models;
    
    @helper AddResourceLinkButton(IPublishedContent resource)
    {
    
      string linkURL = string.Empty;
      string linkTitle = string.Empty;
      string linkIcon = string.Empty;
      string fileName = string.Empty;
      string note = string.Empty;
    
      MultiUrls link = USNUrlHelper.GetSingleURL(resource.GetPropertyValue<MultiUrls>("attachement"), out linkURL, out linkTitle, out linkIcon);
    
      var attachementLink = resource.GetPropertyValue<MultiUrls>("attachement");
    
      if (linkURL != String.Empty)
      {
        switch (link.First().Type)
        {
          case LinkType.External:
            note = "External web link - " + linkURL;
            break;
          case LinkType.Content:
            break;
          case LinkType.Media:
            string fullPathU = Server.MapPath("/") + linkURL;
            FileInfo finfoU = new FileInfo(fullPathU);
            long fileInMBU = finfoU.Length;
            string fileSizeU = fileInMBU.ToFileSize(true);
    
            string linkExt = finfoU.Extension;
            fileName = resource.Name + linkExt;
    
            note = "Download - File size: " + fileSizeU;
            break;
        }
    
        linkTitle = String.Format("{0}{1}", linkTitle ?? resource.GetProperty("optionalAdditionalInformation").Value.NullSafeToString(), note);
    
        <a role="button" href="@linkURL" target="@link.First().Target" @Html.Raw(linkTitle) rel="nofollow,noreferrer"><span>@fileName.ToLower()</span></a>
      }
    }
    
    @helper Traverse(IPublishedContent parent, String attributes)
    {
      <ol @attributes>
    
        @foreach (var resource in parent.Children.Where(x => x.IsVisible()).OrderBy(x => x.SortOrder))
        {
          <li>
            @if ((bool)resource.AncestorOrSelf("USNResourcesSection_AN").GetProperty("useResourceSectionTitle").Value == true)
            {
              <span>@resource.AncestorOrSelf("USNResourcesSection_AN").Name</span>
            }
            @AddResourceLinkButton(resource);
    
            @if (resource.Children.Any())
            {
              @Traverse(resource, "start=\"A\"");
            }
          </li>
        }
      </ol>
    }
    
    
    @if (Model.Children.Where(x => x.IsDocumentType("USNResource")).Count() > 0)
    {
      <ol role="list" class="resource__downloads--listing">
      @foreach (var item in Model.Children.Where(x => x.IsDocumentType("USNResource")).OrderBy(x => x.SortOrder))
      {
        <li>
          @AddResourceLinkButton(item)
          @if (item.AncestorOrSelf("USNResourcesSection_AN").FollowingSibling("USNResourcesSection_AN").Children.Any())
          {
            @Traverse(item, "class=\"resource__downloads--nested\"")
          }
        </li>
      }
      </ol>
    }
    

    Please help me Obi Wan Umbraco, you're my only hope!

  • Lee Kelleher 4026 posts 15836 karma points MVP 13x admin c-trib
    Jun 29, 2015 @ 14:43
    Lee Kelleher
    0

    Hi Jon,

    Which page (doctype) is your Razor script running on?

    I'm guessing that it's the USNResourcesSection_AN pages?

    But do you want this to work higher up the tree? (e.g. on the USNResourcePage pages too)

    Cheers,
    - Lee

  • Marc Love (uSkinned.net) 447 posts 1789 karma points
    Jun 29, 2015 @ 15:56
    Marc Love (uSkinned.net)
    0

    Hi Jon,

    Try looping descendents rather than children:

    @foreach (var item in Model.Descendents.Where(x => x.IsDocumentType("USNResource")).OrderBy(x => x.SortOrder))

  • Jon R. Humphrey 164 posts 455 karma points c-trib
    Jun 29, 2015 @ 17:28
    Jon R. Humphrey
    0

    Thanks all,

    Been head down, taken your thoughts on board:

    @lee - yes that's where the script is due to the partial views of the starter kit

    @Marc - I've changed the direction of attack as I realised I was trying to walk the nodes recursively instead of traversing as I should have.

    I'm almost there I think, just to make sure the node adjustments I've made are right for the end result!

    Feel free to add any other comments!

    Jon

  • Lee Kelleher 4026 posts 15836 karma points MVP 13x admin c-trib
    Jun 30, 2015 @ 09:31
    Lee Kelleher
    0

    Sorry, I didn't mean where was the filepath of the script, but where is it being rendered from on the website, (e.g. which node/URL?)

    I couldn't figure out the context of the Model.

  • Jon R. Humphrey 164 posts 455 karma points c-trib
    Jun 30, 2015 @ 10:03
    Jon R. Humphrey
    0

    @Lee, the Model changes due to the nested partials. Having said that the code is almost there but I'm jumping out of the helper too early now:

    @inherits Umbraco.Web.Mvc.UmbracoViewPage<IPublishedContent>
    
    @using USN.BusinessLogic
    @using RJP.MultiUrlPicker.Models;
    
    @helper AddResourceLinkButton(IPublishedContent resource)
    {
    
      string linkURL = string.Empty;
      string linkTitle = string.Empty;
      string linkIcon = string.Empty;
      string fileName = string.Empty;
      string note = string.Empty;
    
      MultiUrls link = USNUrlHelper.GetSingleURL(resource.GetPropertyValue<MultiUrls>("attachement"), out linkURL, out linkTitle, out linkIcon);
    
      var attachementLink = resource.GetPropertyValue<MultiUrls>("attachement");
    
      if (linkURL != String.Empty)
      {
        switch (link.First().Type)
        {
          case LinkType.External:
            note = "External web link - " + linkURL;
            break;
          case LinkType.Content:
            break;
          case LinkType.Media:
            string fullPathU = Server.MapPath("/") + linkURL;
            FileInfo finfoU = new FileInfo(fullPathU);
            long fileInMBU = finfoU.Length;
            string fileSizeU = fileInMBU.ToFileSize(true);
    
            string linkExt = finfoU.Extension;
            fileName = resource.Name + linkExt;
    
            note = "Download - File size: " + fileSizeU;
            break;
        }
    
      //  linkTitle = String.Format("{0}{1}", linkTitle ?? resource.GetProperty("optionalAdditionalInformation").Value.NullSafeToString(), note);
    
        <a role="button" href="@linkURL" target="@link.First().Target" @Html.Raw(linkTitle) rel="nofollow,noreferrer"><span>@fileName.ToLower()</span></a>
      }
    }
    
    @helper Traverse(IPublishedContent resources, String attributes)
    {
          var siblingResources = resources.Children.Where(x => x.IsDocumentType("USNResource")).OrderBy(x => x.SortOrder);
      <ol @attributes>
    
        @foreach (var resource in siblingResources)
        {
          <li>
            @if ((bool)resource.Parent.GetProperty("useResourceSectionTitle").Value == true)
            {
              <span>@resource.Parent.Name</span>
            }
            @AddResourceLinkButton(resource);
    
            @if (resource.FollowingSibling("USNResourcesSection_AN").Children.Where(x => x.IsDocumentType("USNResource")).Count() > 0){
                @Traverse(resource, "start=\"A\"");
            }
          </li>
        }
      </ol>
    }
    
    
    @if (Model.Children.Where(x => x.IsDocumentType("USNResource")).Count() > 0)
    {
      <ol role="list" class="resource__downloads--listing">
    
      @foreach (var item in Model.Children.Where(x => x.IsDocumentType("USNResource")).OrderBy(x => x.SortOrder))
      {
        <li>
          @AddResourceLinkButton(item)
    
          @if (item.Siblings().Where(x => x.IsDocumentType("USNResourcesSection_AN")).Count() > 0)
          {
            @Traverse(item, "class=\"resource__downloads--nested\"")
          }
        </li>
      }
      </ol>
    }
    

    any thoughts?

    J

  • Jon R. Humphrey 164 posts 455 karma points c-trib
    Jun 30, 2015 @ 10:45
    Jon R. Humphrey
    0

    @Lee, I realised what you were asking and the Model is the USNResourcePage partial "Resources" and "Child Resources" in the amended site structure:

    • Resources (USNResourcePage)
      • Page Components
        • Main Resources (USNResourcesSectionAN)
          • resource.pdf (USNResource)[media]
      • ChildResources (USNResourcePage)
        • Page Components
          • Child Resources1(USNResourcesSectionAN)
            • resource1A.pdf (USNResource)[media]
            • grandChild Resources1 (USNResourcesSection
            AN)
            • resource1A.pdf (USNResource)[media]
            • resource1B.pdf (USNResource)[media]
            • resource1C.pdf (USNResource)[media]
          • grandChild Resources2 (USNResourcesSectionAN)
            • resource2A.pdf (USNResource)[media]
            • resource2B.pdf (USNResource)[media]
          • Does this help?

  • Marc Love (uSkinned.net) 447 posts 1789 karma points
    Jun 30, 2015 @ 12:36
    Marc Love (uSkinned.net)
    0

    Hi Jon,

    I still think your issue is that you are looking for children, not descendants from the Resource Page.

    USNResource is a descendant of the USNResourcePage so using children will not find anything.

    Try changing your code so that you are looking for descendants.

    @if (Model.Descendants.Where(x => x.IsDocumentType("USNResource")).Count() > 0)
    {
      <ol role="list" class="resource__downloads--listing">
    
      @foreach (var item in Model.Descendants.Where(x => x.IsDocumentType("USNResource")).OrderBy(x => x.SortOrder))
      {
    
  • Jon R. Humphrey 164 posts 455 karma points c-trib
    Jun 30, 2015 @ 17:31
    Jon R. Humphrey
    0

    @marc, @lee, et al:

    I can now loop through the parent, children, and grandchildren of the nodelist but I'm exiting the traverse helper too quickly so my nested lists aren't as deep as they should be?

    Amended structure:

    • Resources (USNResourcePage)
      • Page Components
        • Main Resources (USNResourcesSectionAN)
          • resource.pdf (USNResource)[media]
      • ChildResourcePage(USNResourcePage)
        • Page Components
          • Child Resources1(USNResourcesSectionAN)
            • resource1A.pdf (USNResource)[media]
            • Child Resources2(USNResourcesSection
            AN)
            • resource2A.pdf (USNResource)[media]
            • resource2B.pdf (USNResource)[media]
            • resource2C.pdf (USNResource)[media]
          • Child Resources3(USNResourcesSectionAN)
            • resource3A.pdf (USNResource)[media]
            • resource3B.pdf (USNResource)[media]
          • Which in turn renders Main Resources page resources as such:

                <ol role="list" class="resource__downloads--listing">
                    <li><a role="button" href="/media/1075/the-source_.pdf"  rel="nofollow,noreferrer"><span>the-source.pdf</span></a></li>
                    <li><a role="button" href="/media/1076/the-source_.pdf" target="_blank"  title="Link will open in a new window/tab"  rel="nofollow,noreferrer"><span>the-source.pdf</span></a></li>
                    <li><a role="button" href="/media/1081/the-source_.pdf" target="_blank"  title="Link will open in a new window/tab"  rel="nofollow,noreferrer"><span>the-source.pdf</span></a></li>
                    <li><a role="button" href="/media/1078/the-source_.pdf" target="_blank"  title="Link will open in a new window/tab"  rel="nofollow,noreferrer"><span>the-source.pdf</span></a></li>
                    <li><a role="button" href="/media/1073/the-source_.pdf" target="_blank"  title="Link will open in a new window/tab"  rel="nofollow,noreferrer"><span>the-source.pdf</span></a></li>
                    <li><a role="button" href="/media/1074/the-source_.pdf" target="_blank"  title="Link will open in a new window/tab"  rel="nofollow,noreferrer"><span>the-source.pdf</span></a></li>
                    <li><a role="button" href="/media/1077/the-source_.pdf" target="_blank"  title="Link will open in a new window/tab"  rel="nofollow,noreferrer"><span>the-source.pdf</span></a></li>
                    <li><a role="button" href="/media/1083/the-source_.pdf" target="_blank"  title="Link will open in a new window/tab"  rel="nofollow,noreferrer"><span>the-source.pdf</span></a></li>
                    <li><a role="button" href="/media/1080/the-source_.pdf" target="_blank"  title="Link will open in a new window/tab"  rel="nofollow,noreferrer"><span>the-source.pdf</span></a></li>
                    <li><a role="button" href="/media/1085/the-source_.pdf" target="_blank"  title="Link will open in a new window/tab"  rel="nofollow,noreferrer"><span>the-source.pdf</span></a></li>
                    <li><a role="button" href="/media/1079/the-source_.pdf" target="_blank"  title="Link will open in a new window/tab"  rel="nofollow,noreferrer"><span>the-source.pdf</span></a></li>
                    <li><a role="button" href="/media/1082/the-source_.pdf" target="_blank"  title="Link will open in a new window/tab"  rel="nofollow,noreferrer"><span>the-source.pdf</span></a></li>
                    <li><a role="button" href="/media/1084/the-source_.pdf" target="_blank"  title="Link will open in a new window/tab"  rel="nofollow,noreferrer"><span>the-source.pdf</span></a></li>
                </ol>
            

            And the ChildResourcePage resources as such:

                <ol role="list" class="resource__downloads--listing">
                    <li><a role="button" href="/media/1072/the-source_.pdf"  rel="nofollow,noreferrer"><span>the-source.pdf</span></a>
                        <ol class="resource__downloads--nested">
                            <li>
                                Section heading of the Child Resources2 section 
                                <a role="button" href="/media/1088/the-source_.pdf" target="_blank"  title="Link will open in a new window/tab"  rel="nofollow,noreferrer"><span>the-source.pdf</span></a>
                                <ol start="A">
                                    <li><a role="button" href="/media/1086/the-source_.pdf" target="_blank"  title="Link will open in a new window/tab"  rel="nofollow,noreferrer"><span>the-source.pdf</span></a></li>
                                    <li><a role="button" href="/media/1087/the-source_.pdf" target="_blank"  title="Link will open in a new window/tab"  rel="nofollow,noreferrer"><span>the-source.pdf</span></a></li>
                                    <li><a role="button" href="/media/1091/the-source_.pdf" target="_blank"  title="Link will open in a new window/tab"  rel="nofollow,noreferrer"><span>the-source.pdf</span></a></li>
                                    <li><a role="button" href="/media/1092/the-source_.pdf" target="_blank"  title="Link will open in a new window/tab"  rel="nofollow,noreferrer"><span>the-source.pdf</span></a></li>
                                    <li><a role="button" href="/media/1097/the-source_.pdf" target="_blank"  title="Link will open in a new window/tab"  rel="nofollow,noreferrer"><span>the-source.pdf</span></a></li>
                                </ol>
                            </li>
                        </ol>
                    </li>
                </ol>
            

            However the ChildResourcePage should render as such:

                <ol role="list" class="resource__downloads--listing">
                    <li><a role="button" href="/media/1072/the-source_.pdf"  rel="nofollow,noreferrer"><span>the-source.pdf</span></a>
                        <ol class="resource__downloads--nested">
                            <li>
                                Section heading of the Child Resources2 section 
                                <ol start="A">
                                    <li><a role="button" href="/media/1088/the-source_.pdf" target="_blank"  title="Link will open in a new window/tab"  rel="nofollow,noreferrer"><span>A1 the-source.pdf</span></a></li>
                                </ol>
                            </li>
                            <li>
                                Section heading of the Child Resources3 section
                                <ol start="B">
                                    <li><a role="button" href="/media/1086/the-source_.pdf" target="_blank"  title="Link will open in a new window/tab"  rel="nofollow,noreferrer"><span>B1 the-source.pdf</span></a></li>
                                    <li><a role="button" href="/media/1087/the-source_.pdf" target="_blank"  title="Link will open in a new window/tab"  rel="nofollow,noreferrer"><span>B2 the-source.pdf</span></a></li>
                                    <li><a role="button" href="/media/1091/the-source_.pdf" target="_blank"  title="Link will open in a new window/tab"  rel="nofollow,noreferrer"><span>B3 the-source.pdf</span></a></li>
                                    <li><a role="button" href="/media/1092/the-source_.pdf" target="_blank"  title="Link will open in a new window/tab"  rel="nofollow,noreferrer"><span>B4 the-source.pdf</span></a></li>
                                    <li><a role="button" href="/media/1097/the-source_.pdf" target="_blank"  title="Link will open in a new window/tab"  rel="nofollow,noreferrer"><span>B5 the-source.pdf</span></a></li>
                                </ol>
                            </li>
                        </ol>
                    </li>
                </ol>
            

            And finally the updated current partial view code that needs updating:

                @inherits Umbraco.Web.Mvc.UmbracoViewPage<IPublishedContent>
            
                @using USN.BusinessLogic
                @using RJP.MultiUrlPicker.Models;
            
                @helper AddResourceLinkButton(IPublishedContent resource, string prefixer = "")
                {
                    int loop = 1;
                    string linkURL = string.Empty;
                    string linkTitle = string.Empty;
                    string linkIcon = string.Empty;
                    string fileName = string.Empty;
                    string note = string.Empty;
            
                    MultiUrls link = USNUrlHelper.GetSingleURL(resource.GetPropertyValue<MultiUrls>("attachement"), out linkURL, out linkTitle, out linkIcon);
            
                    var attachementLink = resource.GetPropertyValue<MultiUrls>("attachement");
            
                    if (linkURL != String.Empty)
                    {
                        switch (link.First().Type)
                        {
                            case LinkType.External:
                                note = "External web link - " + linkURL;
                                break;
                            case LinkType.Content:
                                break;
                            case LinkType.Media:
                                string fullPathU = Server.MapPath("/") + linkURL;
                                FileInfo finfoU = new FileInfo(fullPathU);
                                long fileInMBU = finfoU.Length;
                                string fileSizeU = fileInMBU.ToFileSize(true);
            
                                string linkExt = finfoU.Extension;
                                fileName = prefixer.Length > 0 ? prefixer + loop + " " + resource.Name + linkExt : resource.Name + linkExt;
                                loop++;
            
                                note = "Download - File size: " + fileSizeU;
                                break;
                        }
            
                    //  linkTitle = String.Format("{0}{1}", linkTitle ?? resource.GetProperty("optionalAdditionalInformation").Value.NullSafeToString(), note);
            
                        <a role="button" href="@linkURL" target="@link.First().Target" @Html.Raw(linkTitle) rel="nofollow,noreferrer"><span>@fileName</span></a>
                    }
                }
            
                @helper Traverse(IPublishedContent resources)
                {
                    int counter = 1;
                    var childResources = resources.Children.Where(x => x.IsDocumentType("USNResource")).OrderBy(x => x.SortOrder);
            
                    foreach (var resource in childResources)
                    {
                        <li>
                        @if (resource.Parent.FollowingSibling("USNResourcesSection_AN") != null)
                        {
                            if (((bool)resource.Parent.GetProperty("useResourceSectionTitle").Value == true))
                            {
                                @resource.Parent.Name
                            }
            
                            @AddResourceLinkButton(resource, counter.IntToLetters())
            
                            <ol start="@counter.IntToLetters()">
                                @Traverse(resource.Parent.FollowingSibling("USNResourcesSection_AN"))
                            </ol>
                        }
                        else
                        {
                            @AddResourceLinkButton(resource, counter.IntToLetters())
                        }
                        </li>
                        counter++;
                    }
                }
            
                <!-- Model is resource section -->
                @if (Model.Children.Where(x => x.IsDocumentType("USNResource")).Count() > 0)
                {
                    <ol role="list" class="resource__downloads--listing">
                    @foreach (var resource in Model.Children.Where(x => x.IsDocumentType("USNResource")).OrderBy(x => x.SortOrder))
                    {
                        <li>
                        @AddResourceLinkButton(resource)
                        @if (resource.Siblings().Where(x => x.IsDocumentType("USNResourcesSection_AN")).Count() > 0)
                        {
                            <ol class="resource__downloads--nested">
                                @Traverse(resource.FollowingSibling("USNResourcesSection_AN"))
                            </ol>
                        }
                        </li>
                    }
                    </ol>
                }
            

            Thanks everyone!

  • Lee Kelleher 4026 posts 15836 karma points MVP 13x admin c-trib
    Jul 01, 2015 @ 09:51
    Lee Kelleher
    0

    Hi Jon,

    To be honest, I'm getting a bit cross-eyed with the script, (although I'm not sure if that's the colour/styling of the code-block on the forum?).

    You could try swapping the .Parent reference in this line:

    @Traverse(resource.Parent.FollowingSibling("USNResourcesSection_AN"))
    

    ... to ...

    @Traverse(resources.FollowingSibling("USNResourcesSection_AN"))
    

    ... but I'm not entirely sure if that solves the overall problem?

    Cheers,
    - Lee

  • Jon R. Humphrey 164 posts 455 karma points c-trib
    Jul 05, 2015 @ 21:43
    Jon R. Humphrey
    100

    Just to say thanks to @Marc and @Lee for their help as it gave me the chance to loop through and keep debugging until the issue was resolved! <3

    For future readers, I ended up changing the main loop and the final element structure as well as removing the traverse loop to step through the lists.

    If anyone has any further thoughts please feel free to comment!

    @inherits Umbraco.Web.Mvc.UmbracoViewPage<IPublishedContent>
    
    @using USN.BusinessLogic
    @using RJP.MultiUrlPicker.Models;
    
    @helper AddResourceLinkButton(IPublishedContent resource, string prefixer = "", int loop = 0)
    {
      var linkURL = string.Empty;
      var linkTitle = string.Empty;
      var linkIcon = string.Empty;
      var fileName = string.Empty;
      var note = string.Empty;
    
      MultiUrls link = USNUrlHelper.GetSingleURL(resource.GetPropertyValue<MultiUrls>("attachement"), out linkURL, out linkTitle, out linkIcon);
    
      var attachementLink = resource.GetPropertyValue<MultiUrls>("attachement");
    
      if (linkURL == string.Empty)
      {
        return;
      }
      switch (link.First().Type)
      {
        case LinkType.External:
          note = "External web link - " + linkURL;
          break;
        case LinkType.Content:
          break;
        case LinkType.Media:
          string fullPathU = Server.MapPath("/") + linkURL;
          FileInfo finfoU = new FileInfo(fullPathU);
          long fileInMBU = finfoU.Length;
          string fileSizeU = fileInMBU.ToFileSize(true);
    
          string linkExt = finfoU.Extension;
          fileName = prefixer.Length > 0 && loop > 0 ? prefixer +""+ loop + " " + resource.Name + linkExt : resource.Name + linkExt;
    
          note = "Download - File size: " + fileSizeU;
          break;
      }
    
      //  linkTitle = String.Format("{0}{1}", linkTitle ?? resource.GetProperty("optionalAdditionalInformation").Value.NullSafeToString(), note);
    
      <a role="button" href="@linkURL" target="@link.First().Target" @Html.Raw(linkTitle) rel="nofollow,noreferrer"><span>@fileName</span></a>
    }
    
    @*@helper Traverse(IPublishedContent resources)
    {
      var counter = 1;
      var loop = 1;
    
      if (resources == null)
      {
        return;
      }
      var childResources = resources.Children.Where(x=>x.IsDocumentType("USNResource")).OrderBy(x=>x.SortOrder);
      foreach (var resource in childResources)
      {
        <li>
          @if ((bool)resource.Parent.GetProperty("useResourceSectionTitle").Value == true)
          {
            @resource.Parent.Name
            if (resource.Siblings().Any())
            {
              if (resource.FollowingSibling() != null)
              {
                <ol start="@counter.IntToLetters()">
                  @Traverse(resource.FollowingSibling())
                </ol>
              }
            }
          }
          else
          {
            @AddResourceLinkButton(resource, counter.IntToLetters(), loop)
            loop++;
          }
        </li>
        counter++;
      }
    }*@
    
    <!-- Model is resource section -->
    @if (Model.Children.Any())
    {
      var counter = 1;
      <ol role="list" class="resource__downloads--listing">
      @foreach (var resource in Model.Children.Where(x => x.IsDocumentType("USNResource")).OrderBy(x => x.SortOrder))
      {
        <li>
        @AddResourceLinkButton(resource)
    
        @{
        //Check if there's Siblings exit if not
        if (!resource.Siblings().Any())
        {
          return;
        }
    
        foreach (var siblingResource in resource.Siblings().Where(x => x.IsDocumentType("USNResourcesSection_AN")).OrderBy(x => x.SortOrder))
        {
          var loop = 1;
          <ol class="resource__downloads--nested" start="@counter">
            <li>
              @if (!siblingResource.Children().Any())
              {
                return;
              }
    
              @if ((bool)siblingResource.GetProperty("useResourceSectionTitle").Value == true)
              {
                @siblingResource.Name
              }
    
              @{
                <ol start="@counter.IntToLetters()">
                  @foreach (var childResource in siblingResource.Children.Where(x => x.IsDocumentType("USNResource")).OrderBy(x => x.SortOrder))
                  {
                    <li>
                      @AddResourceLinkButton(childResource, counter.IntToLetters(), loop)
                    </li>
                    loop++;
                  }
                </ol>
              }
            </li>
          </ol>
          counter++;
        }
        }
        </li>
        }
      </ol>
    }
    

    h5yr!

Please Sign in or register to post replies

Write your reply to:

Draft