Press Ctrl / CMD + C to copy this to your clipboard.
This post will be reported to the moderators as potential spam to be looked at
I have one articles list (parent node) and article detail (child node) document type. In article list document type I have taken Header section background image, HeaderText and SEO modules property.
In article detail screen I have numbers of column like Article Name, Article date, Article Image, description property etc.
As per above I nested the article detail with article list and using query builder I render article list in front-end with order by descending created date. Please refer below query.
var section = Umbraco.Content(Guid.Parse("7c4e163e-cd41-42c1-af3e-26bfd0530d7c"))
.Where(x => x.IsVisible())
.OrderByDescending(x => x.CreateDate)
But my requirement is I need display article list based on article date which property available in article detail page. so problem with query builder I can`t access children property in where condition and set the list in order by descending with article date property. So any one know how to access children property in MVC RAZOR of Umbraco 8.1.0 version.
Second problem is I can`t access parent Header Background Image in child template view just like
So if you have solution about this can you please help me so I can work with common component without add every time new property child node.
Thanks in Advance.
Would I be write in thinking you are after something like this?
var section = Umbraco.Content(Guid.Parse("7c4e163e-cd41-42c1-af3e-26bfd0530d7c")) .ChildrenOfType("createArticle") .Where(x => x.IsVisible()) .OrderByDescending(x => x.HasValue("articleDate") ? x.Value<DateTime>("articleDate") : x.CreateDate);
and in your article template page, if you want to read the property from the article list document type, you can use 'Fallback.ToAncestors' which will recurse up the content tree until it finds a property of that alias that is populated:
var newsListBackgroundImage = Model.Value<IPublishedContent>("backgroundImage", fallback: Fallback.ToAncestors)
Thanks Marc Goodson,
Its work both solutions I can easily access parent - child property in list and access parent image in child view.
Again Thank you so much for quick response.
Great Mihir! - glad that you have gotten it working!
is working on a reply...
Write your reply to:
Image will be uploaded when post is submitted