Copied to clipboard

Flag this post as spam?

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


  • hrcodenstuff 6 posts 128 karma points
    Oct 16, 2016 @ 02:28
    hrcodenstuff
    0

    Cannot get Descendants of Specific Document Type to Show

    I have been working for hours trying to get a Partial View Macro for displaying a simple list of document types to work. I have tried virtually everything on this forum, as well as other sites, and it simply won't work.

    When I simplify this by leaving out the Document Type parameter, it works fine (I get a list of every page on the site):

    inherits Umbraco.Web.Macros.PartialViewMacroPage
    
    @{
        var list = CurrentPage.AncestorOrSelf("Home").Descendants();
    
    }
    <ul>
        @foreach(var item in list){ 
            <li>
                <p>@item.Name</p>
            </li>
        }
    </ul>
    

    However, if I add the name of the Document Type, I get a blank list:

    [snip] var list = CurrentPage.AncestorOrSelf("Home").Descendants("ProductDetails");
    

    I have multiple pages of this document type published; they appear just fine in my site navigation.

    What am I doing wrong?!?! Any and all help with this is most appreciated!

  • hrcodenstuff 6 posts 128 karma points
    Oct 16, 2016 @ 02:52
    hrcodenstuff
    100

    OK, folks - I figured this out on my own. It's a "newbie" issue, but just in case someone else does the same thing I did, I'm passing this along to prevent someone else going through the same pain.

    In the Documentation, I noticed a property called DocumentTypeAlias, so I decided to add this to the code that I was getting to work to see if there was something unexpected happening. Sure enough, all the pages had something different than what I thought was the "alias". I was expecting this to be the Document Type "title"; however, what I was getting was something completely different!

    I did not notice the tiny "alias" icon to the right of the Document Type Title text box:

    enter image description here

    Once I unlocked this, changed it to what I intended, and republished, things worked like a charm!

    Hope this helps another newbie in the future!

Please Sign in or register to post replies

Write your reply to:

Draft