So... how would I use this IN a custom grid docType
So, using both your AWESOME new packages together... how would i get at the properties of a nested content item in a grid docType? I can get the name like this... but how do i list the custom properties?
@inherits Umbraco.Web.Mvc.UmbracoViewPage
@{
var items = Model.GetPropertyValue>("CarouselItems");
foreach(var item in items) {
// Do your thang...
With accessing the Nested Content values, you can use the IEnumerable<IPublishedContent> type.
var items = Model.GetPropertyValue<IEnumerable<IPublishedContent>>("CarouselItems");
Then inside the loop, you can access the item's inner properties using GetPropertyValue<T>:
foreach(var item in items)
{
// Do your thang...
@item.Name
@item.GetPropertyValue("propertyAlias")
// ... or ...
@(item.GetPropertyValue<string>("propertyAlias"))
}
Bob, I had the same problem with a Nested Content inside a DocType Grid Editor. I could get the ID using GetPropertyValue, but GetPropertyValue<IPublishedContent> returned null.
OTB NC, doesn't come with any value converters installed so to have a link node return IPublishedContent, you need to have a value converter defined that does this. The easiest way to do this for common datatypes is to install Jeavons Umbraco Core Property Value Converters package here https://our.umbraco.org/projects/developer-tools/umbraco-core-property-value-converters. This should then return you the IPublishedContent you require.
So... how would I use this IN a custom grid docType
So, using both your AWESOME new packages together... how would i get at the properties of a nested content item in a grid docType? I can get the name like this... but how do i list the custom properties?
Hi Bob,
Thanks for the praise! :-)
With accessing the Nested Content values, you can use the
IEnumerable<IPublishedContent>
type.Then inside the loop, you can access the item's inner properties using
GetPropertyValue<T>
:Hope this helps?
Cheers,
- Lee
BOOM!
building a carousel now ;)
okay, continuing on... i know this is programming 101, but me != developer...
how do you avoid the object not set to instance with a call like this?
carouselContentLink is a content picker????
Hey Bob, replied with a fix in your other post.
https://our.umbraco.org/projects/backoffice-extensions/nested-content/nested-content-feedback/63386-Property-converters-still-error
Many thanks
Matt
Bob, I had the same problem with a Nested Content inside a DocType Grid Editor. I could get the ID using GetPropertyValue, but GetPropertyValue<IPublishedContent> returned null.
Hey Jason,
OTB NC, doesn't come with any value converters installed so to have a link node return IPublishedContent, you need to have a value converter defined that does this. The easiest way to do this for common datatypes is to install Jeavons Umbraco Core Property Value Converters package here https://our.umbraco.org/projects/developer-tools/umbraco-core-property-value-converters. This should then return you the IPublishedContent you require.
Matt
Yep, I thought I nugetted that package in, but there must have been an issue I missed. Installed it as a package and it worked great.
Sorry about that!
Thanks,
Jason
is working on a reply...