Copied to clipboard

Flag this post as spam?

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


  • Nicky Christensen 76 posts 166 karma points
    Oct 17, 2012 @ 10:15
    Nicky Christensen
    0

    Why dont i get all the news items nodes?

    Hey Guys...

    Im trying to loop all nodes through, and I want to get all the items with the NodeTypeAlias "NewsItem"
    However, im not getting any results?

    My sitetree look like (In every "news" folder, i have News items:

    - Homepage
    - Solutions
    - News
    - Technics
    -News
    - Asia
    - News
    - Leasing
    - News

     

    The script looks like: 

    @foreach(var item in @Model.AncestorOfSelf().Descendants("NewsItem").OrderBy("NewsDate desc").Take(5))
    
        {
           <article class="news">
             <h2><a href="@item.Url">@item.Name</a></h2>
              <p>
                 @Html.Raw(@item.summary);
                 <a href="@item.Url">Read more</a>
              </p>
           </article>
          }
    
  • Fuji Kusaka 2203 posts 4220 karma points
    Oct 17, 2012 @ 11:15
    Fuji Kusaka
    0

    Hi Nicky,

    Try changing

    AncestorOfSelf to AncestorOrSelf()
  • Nicky Christensen 76 posts 166 karma points
    Oct 17, 2012 @ 13:10
    Nicky Christensen
    0

    Ahhhh, didn't see I spelled it wrong :) Thx :) 

  • Fuji Kusaka 2203 posts 4220 karma points
    Oct 17, 2012 @ 14:09
    Fuji Kusaka
    0

    Did you get it working though?

  • Nicky Christensen 76 posts 166 karma points
    Oct 17, 2012 @ 14:27
    Nicky Christensen
    0

    Yeah, works perfectly

Please Sign in or register to post replies

Write your reply to:

Draft