Copied to clipboard

Flag this post as spam?

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


  • Tony Kiernan 278 posts 341 karma points
    Jul 27, 2011 @ 13:01
    Tony Kiernan
    0

    Get all nodes of a specifice document type

    I have various news sections on a site.  I want to pull all the nodes of Document Type "NewsItem" together a main news page.  I can work out how to do this.  It seems to me that

    @Model.Ancestors().Where("nodeTypeAlias = 'NewsItem'")

    should work.  But, it doesn't

  • Sebastiaan Janssen 4899 posts 14655 karma points MVP admin hq
    Jul 27, 2011 @ 13:05
    Sebastiaan Janssen
    0

    You're almost there! Try:

    @Model.Ancestor().Descendants("NewsItem")
  • Tony Kiernan 278 posts 341 karma points
    Jul 27, 2011 @ 13:25
    Tony Kiernan
    0

    Hmm I must be doing something else wrong

  • Tony Kiernan 278 posts 341 karma points
    Jul 27, 2011 @ 13:28
    Tony Kiernan
    0
    @inherits umbraco.MacroEngines.DynamicNodeContext
    @{
        var news_items = @Model.Ancestor().Descendants("NewsItem");
      
                <ul>
                    @foreach (var news_item in news_items) {
                        <li>
                            @news_item.Name
                        </li>
                    }
                </ul>
    }
  • Tony Kiernan 278 posts 341 karma points
    Jul 27, 2011 @ 13:29
    Tony Kiernan
    0

    Copy/paste madness.  That's (kinda) my code.

    Such a change just as I was geting used to xslt

  • Sebastiaan Janssen 4899 posts 14655 karma points MVP admin hq
    Jul 27, 2011 @ 13:34
    Sebastiaan Janssen
    0

    Ah, unfortunately in 4.7.0 it seems you need to use AncestorOrSelf() instead of Ancestor(). This will be corrected in the upcoming 4.7.1.

  • Tony Kiernan 278 posts 341 karma points
    Jul 27, 2011 @ 13:38
    Tony Kiernan
    0

    Thank you very much

  • Carlos 338 posts 472 karma points
    Jun 20, 2012 @ 21:19
    Carlos
    0

    Is there a way to get the NodeType ID instead of the NodeTypeAlias?

  • 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