I am trying to access content from my level 2 document type from a sub level. level 2 has multiple pages of same document type.
I am using the code below
var rootByTraversing = Umbraco.AssignedContentItem.AncestorOrSelf(2);
var openingTimesByDescendants = rootByTraversing.Descendants().Where(f => f.DocumentTypeAlias == "PageLevel2").FirstOrDefault();
Is it possible for me to get the immediate parent node of this document type and not FirstOrDefault node?
I don't want to access the content through node id.
Umbraco.AssignedContentItem returns an IPublishedContent
To get the parent of a node represented as an IPublischedContent call .Parent
To go higher up the tree, use .AncestorOrSelf(1basedIndexOfTheLevelYouWantToReach)
Try and avoid using .Descendants() because it loads in all nodes below the one you are calling from, this can have serious performance implications on bigger sites.
Accesing the content from immediate parent
I am trying to access content from my level 2 document type from a sub level. level 2 has multiple pages of same document type. I am using the code below
Is it possible for me to get the immediate parent node of this document type and not FirstOrDefault node?
I don't want to access the content through node id.
Umbraco.AssignedContentItem returns an
IPublishedContent
To get the parent of a node represented as an
IPublischedContent
call.Parent
To go higher up the tree, use.AncestorOrSelf(1basedIndexOfTheLevelYouWantToReach)
Try and avoid using
.Descendants()
because it loads in all nodes below the one you are calling from, this can have serious performance implications on bigger sites.is working on a reply...