Copied to clipboard

Flag this post as spam?

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


  • Matthew 93 posts 153 karma points
    Jun 10, 2012 @ 00:05
    Matthew
    0

    How to display a list of sub pages from all other pages

    Sorry, dummy question, still banging my head on it after a week though.

    I have a products node, with sub nodes for categories and types, then the individual product pages under each of those.

    I've made a razor macro with nested foreach's that displays the full list of products by category/type/product in a sidebar but it only shows up from the Products page, the one that all the rest of them are under.

    Nothing shows up in the sidebar from the Home or other pages.

    I've been dinking around with sitemap, AncestorOrSelf, Decendants, Model.DocumentType, etc, but I can't figure out how to get it to always show the listing of the one branch regardless which page you're on.

  • Fuji Kusaka 2203 posts 4220 karma points
    Jun 10, 2012 @ 07:21
    Fuji Kusaka
    0

    Hi Matthew,

    Can you please show us your code and give an example of your content tree?

    //fuji

  • Matthew 93 posts 153 karma points
    Jun 10, 2012 @ 09:47
    Matthew
    0

    Well, I got this to work (I lied, I guess there's 3 layers), but it is soooo slooooowww:

    <ul>
     @foreach (var page in @Model.AncestorOrSelf().ProductList)
     {
      if (page.Childen != null && page.Children.Count() > 0)
      {
       <ul>
        @foreach (dynamic secondPage in page.Children)
        {
         <li>
          <h3><a href="@secondPage.Url">@secondPage.Name</a></h3>
          @if (secondPage.Childen != null && secondPage.Children.Count() > 0)
          {
           <ul>
            @foreach (dynamic thirdPage in secondPage.Children)
            {
             <li>
              <h4><a href="@thirdPage.Url">@thirdPage.Name</a></h4>
              @if (thirdPage.Childen != null && thirdPage.Children.Count() > 0)
              {
               <ul>
                @foreach (dynamic fourthPage in thirdPage.Children)
                {
                 <li>
                  <h4><a href="@fourthPage.Url">@fourthPage.Name</a></h4>
                  @if (fourthPage.Childen != null && fourthPage.Children.Count() > 0)
                  {
                   <ul>
                    @foreach (dynamic fifthPage in fourthPage.Children)
                    {
                     <li>
                      <h4><a href="@fifthPage.Url">@fifthPage.Name</a></h4>
                     </li>
                    }
                   </ul>
                  }
                 </li>
                }
               </ul>
              }
             </li>
            }
           </ul>
          }
         </li>
        }
       </ul>
      }
     }
    </ul>

    The content looks like:

    Home
    -Products
    --Group1
    ---Category1
    ----Type1
    -----Product1
    -----Product2
    ----Type2
    -----Product3
    -----Product4
    ---Category2
    ----Type2
    -----Product5
    -----Product6
    --Group2
    ---Category3
    etc, etc, etc.
    -About
    -Contact

    The included Razor macros like the SiteMap are so fast, compared to what I've done, I'd sure like to find a way to take advantage of them.  I just could not figure out a way to get them to start at Products, instead of Home.

    I don't know if it matters that each product has ~25 properties, about a third of which will be images.  Ultimately there will be about 200 of them.  Seems like performance will only get even worse as I poplulate the site with data.

    Thanks very much for any help.

    Matthew

     

  • Matthew 93 posts 153 karma points
    Jun 10, 2012 @ 20:31
    Matthew
    0

    I've also been messing around with adding a 'ShowInSideNav' property and adding that in a .Where filter in the simpler/faster sitemap macro but it doesn't seem to work they way I'm using it.

       var items = node.Children.Where("Visible").Where("Level <= maxLevelForSitemap", values).Where("ShowInSideNav");

    Maybe it blows up because that's not in the first level so it doesn't look farther.

    I'm going to try the Model.Down().Next() shown in Gareth Evans, Feature Walkthrough.

    http://umbraco.com/follow-us/blog-archive/2011/3/13/umbraco-razor-feature-walkthrough-part-5.aspx

    but I'm not too optomistic.

    Thanks again.

Please Sign in or register to post replies

Write your reply to:

Draft