Traversing extentsion methods are missing from Umbraco.Core.Models.IPublishedContent
According to the v8 documentation here, there should be these extension methods available on Umbraco.Core.Models.IPublishedContent:
Children() // this is the same as using the Children property on the content item.
Ancestors()
Ancestors(int level)
Ancestors(string nodeTypeAlias)
AncestorsOrSelf()
AncestorsOrSelf(int level)
AncestorsOrSelf(string nodeTypeAlias)
Descendants()
Descendants(int level)
Descendants(string nodeTypeAlias)
DescendantsOrSelf()
DescendantsOrSelf(int level)
DescendantsOrSelf(string nodeTypeAlias)
Siblings()
SiblingsAndSelf()
Ancestor()
AncestorOrSelf()
AncestorOrSelf(int level)
AncestorOrSelf(string nodeTypeAlias)
AncestorOrSelf(Func<IPublishedContent, bool> func)
However, in my Umbraco 8.5.3 project, IPublishedContent items are missing all of these extension methods. All I see is .Children and .Parent
Also I checked the API documentation, and there, the above stated extension methods are not documented as well.
Is the documentation wrong (meaning, these extension methods have been removed), or is there something funny with my project?
Traversing extentsion methods are missing from Umbraco.Core.Models.IPublishedContent
According to the v8 documentation here, there should be these extension methods available on
Umbraco.Core.Models.IPublishedContent
:However, in my Umbraco 8.5.3 project,
IPublishedContent
items are missing all of these extension methods. All I see is.Children
and.Parent
Also I checked the API documentation, and there, the above stated extension methods are not documented as well.
Is the documentation wrong (meaning, these extension methods have been removed), or is there something funny with my project?
Because they are extensions you need to be using the namespace in the top of your class. If you are in a .cshtml file you need to add @ before using: https://stackoverflow.com/questions/3239006/how-do-i-import-a-namespace-in-razor-view-page
The namespace should be Umbraco.Web.PublishedContentExtensions: https://github.com/umbraco/Umbraco-CMS/blob/eed94d8cd03b04385c244a8f593e01e95f349218/src/Umbraco.Web/PublishedContentExtensions.cs So you need to have Umbraco.Web installed and referenced to be able to use these extensions.
Hope this helps a little bit. :-)
@Malthe: great, thank you! I was missing
using Umbraco.Web;
as simple as that..... embarrassing! :-)
Glad I could help. Sometimes the simplest solution is the hardest. :-)
is working on a reply...