hopefully this is a simple question and its just a case of pointing me in the direction of the correct method..
given a property based on the MNTP in umbraco 6, how do i obtain its nodes in a strongly typed fashion? (is there a built in way that doesn't involve the 'dynamic' namepace or a package?)
I was wondering if those uQuery methods had been updated or superceeded in umbraco 6 to deal with IPublishedContent rather than Node?
I was reading this post from Shannon where he says that the old Node libraries are still there of course, but you shouldn't actually need to use them other than for backwards compatibility: http://shazwazza.com/post/Native-MVC-support-in-Umbraco-coming-very-soon! uQuery is still using the old Node libraries by the looks of things.
There is an example here thats using TypedContent:
but that doesn't check those node ids are actually valid/published.
If there is nothing currently in the Core for doing this then it appears my best option is to wrap TypedContent in my own extension method and check the items are actually published?
You can either create an extension method to do that for you, or you can create your own IPropertyEditorValueConverter for MNTP. We need to create more value converters as part of the core, there's already an issue logged for that here: http://issues.umbraco.org/issue/U4-1313
MNTP in Umbraco 6 - helper method?
hopefully this is a simple question and its just a case of pointing me in the direction of the correct method..
given a property based on the MNTP in umbraco 6, how do i obtain its nodes in a strongly typed fashion? (is there a built in way that doesn't involve the 'dynamic' namepace or a package?)
Have a look at uQuery.
There are 2 methods that can help you, depending how you have configured the node picker (xml or csv)
uQuery.GetNodesByCsv(string)
uQuery.GetNodesByXml(string)
More documentation can be found here : http://our.umbraco.org/documentation/Reference/Querying/uQuery/Content/Nodes
Dave
hi dawoe, thanks for the info.
I was wondering if those uQuery methods had been updated or superceeded in umbraco 6 to deal with IPublishedContent rather than Node?
I was reading this post from Shannon where he says that the old Node libraries are still there of course, but you shouldn't actually need to use them other than for backwards compatibility: http://shazwazza.com/post/Native-MVC-support-in-Umbraco-coming-very-soon! uQuery is still using the old Node libraries by the looks of things.
There is an example here thats using TypedContent:
https://github.com/Shandem/Umbraco4Docs/blob/4.8.0/Documentation/Reference/Mvc/querying.md
ie. @Umbraco.TypedContent(1234, 4321, 1111, 2222)
but that doesn't check those node ids are actually valid/published.
If there is nothing currently in the Core for doing this then it appears my best option is to wrap TypedContent in my own extension method and check the items are actually published?
for example, given a MNTP called "featuredItems" im currently doing this to obtain published content items within my homepage view:
var featuredItems = Umbraco.TypedContent(Model.Content.GetPropertyValue<string>("featuredItems").Split(','))
.ToList()
.WhereNotNull();
but I'd obviously rather not have all of that logic in a view.
You can either create an extension method to do that for you, or you can create your own IPropertyEditorValueConverter for MNTP. We need to create more value converters as part of the core, there's already an issue logged for that here: http://issues.umbraco.org/issue/U4-1313
cool Shannon, thanks for the info and link. I'll take a look into IPropertyEditorValueConverter
is working on a reply...