I've a site with a blog page - All blogItems are sorted under each Blogger - However the blogger is not displayed on the webpage, but info about the blogger is displayed on each blogItm instead... - here's how my nodetree looks like:
Root
+ Blogs (nodeId: 1234)
+ + Blogger (<-- this is not displayed on the web)
+ + + BlogItem (<-- theese are linked to directly from Blogs)
+ + + BlogItem
+ + + BlogItem
What I would like to do is display a table of the 9 latest active Blogger - here's how my code looks like:
@{ var startNode = 1234; var items = startNode.Descendants(); } <table class="table bloggers"> @foreach (var page in items.OrderBy("CreateDate desc").Take(9).InGroupsOf(3)) { <tr> @foreach (var row in page) { <td><a href="@row.Url" title="@row.Parent.blogAuthor"><img src="@Umbraco.Content(row.Parent.id).GetCropUrl("blogImage", "blogger_thumb")" class="img-responsive" alt="@row.Parent.blogAuthor" /></a></td> } </tr> } </table>
So far several bloggers are displayed multiple times - how can I make the list of Bloggers distincive...?
Get a distinct list of Parent.Id's
I've a site with a blog page - All blogItems are sorted under each Blogger - However the blogger is not displayed on the webpage, but info about the blogger is displayed on each blogItm instead... - here's how my nodetree looks like:
Root
+ Blogs (nodeId: 1234)
+ + Blogger (<-- this is not displayed on the web)
+ + + BlogItem (<-- theese are linked to directly from Blogs)
+ + + BlogItem
+ + + BlogItem
What I would like to do is display a table of the 9 latest active Blogger - here's how my code looks like:
So far several bloggers are displayed multiple times - how can I make the list of Bloggers distincive...?
http://stackoverflow.com/questions/19406242/select-distinct-using-linq
I think you should have something like this :
startNode.Descendants.OrderByDescending(x => x.CreateDate).Distinct(x => x.Parent).Take(9)
This is untested.
This one nailed it - Dawoe U Rock >:-)
is working on a reply...