Descendants(String) stops returning expected nodes after child of descendant gets published
I'm trying to replace the places in my templates where I look up nodes by nodeId to look up nodes by their documentType and where they appear in the node hierarchy.
// original reference
var content = Umbraco.Content(1000);
// new version
var current = CurrentPage.AncestorOrSelf();
var content = current.Descendants("ContentDocumentType");
The new version works inconsistently. If I leave the Umbraco.Content(1000) above the new code (without declaring content), then current.Descendants("ContentDocumentType") returns something, but if I remove that line and publish a different node (specifically a childnode of the ContentDocumentType node), then current.Descendants("ContentDocumentType") returns an empty collection.
Why does current.Descendants("ContentDocumentType") behave inconsistently?
Is there a better way to retrieve nodes without looking them up by nodeId?
Descendants(String) stops returning expected nodes after child of descendant gets published
I'm trying to replace the places in my templates where I look up nodes by nodeId to look up nodes by their documentType and where they appear in the node hierarchy.
The new version works inconsistently. If I leave the
Umbraco.Content(1000)
above the new code (without declaring content), thencurrent.Descendants("ContentDocumentType")
returns something, but if I remove that line and publish a different node (specifically a childnode of the ContentDocumentType node), thencurrent.Descendants("ContentDocumentType")
returns an empty collection.Why does
current.Descendants("ContentDocumentType")
behave inconsistently?Is there a better way to retrieve nodes without looking them up by nodeId?
Thanks in advance.
Hi Danny,
Have you tried specifying the level as 1? e.g.
Jeavon
is working on a reply...