Just about to add my first ever nested content control and I'm very happy about it.
There's one potential complication that I'd appreciate any advice on.
I'm going to do two implementations. One with a set of optional items to add, and first one with a single item which will also be reused in the first implementation. I'll do the second one first as it's hopefully a bit simpler to start with.
The point of complication is that the site I'm adding it to extensively uses uSiteBuilder and I have to retain this. So document type properties are typically defined as something like:
[DocumentTypeProperty(UmbracoPropertyType.Other, OtherTypeName = "Multiple Media Picker", Name = "Carousel", Alias = "headerCarousel", Tab = TabNames.Header)]
public List<int> Carousel { get; set; }
What I'm curious about is what is the best thing to set as the public property for this document type, i.e. the public List< int > part above.
The site also extensively uses automapper so I will have to try and convert what is returned there into a usable object. Any advice appreciated also on how to best approach that.
Damn (now I'll admit I'm not really a fan of uSiteBuilder) this
throws a very annoying error.
Cannot set the value of a document type property DestinationItemDT.Quote (document type: Umbraco.Core.Models.IPublishedContent) to value: '' (value type: ). Error: Invalid cast from 'System.String' to 'Umbraco.Core.Models.IPublishedContent'.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.Exception: Cannot set the value of a document type property DestinationItemDT.Quote (document type: Umbraco.Core.Models.IPublishedContent) to value: '' (value type: ). Error: Invalid cast from 'System.String' to 'Umbraco.Core.Models.IPublishedContent'.
I'll have to see what I can do.
If I do get the json as a string is there an easy way to convert it back to an IPublishedContent?
I'm using every dignified bone/nerve in my body to stop me saying sarcastic things about having to use usb here. I live in an idealistic universe where I hope by exposing them to the sheer goodness of NC it will broaden their horizons!
No I gave it a good hour, but couldn't get that to work there. The main issue is getting the PropertyType to pass through. Can't think of any good way of generically doing that, couldn't even quite find a way just to create one of the known correct type.
Anyway JArray has done the job nicely and happily works with automapper too!
Thank you again for pointing me in the right directions.
Nested Content with USiteBuilder
Just about to add my first ever nested content control and I'm very happy about it.
There's one potential complication that I'd appreciate any advice on.
I'm going to do two implementations. One with a set of optional items to add, and first one with a single item which will also be reused in the first implementation. I'll do the second one first as it's hopefully a bit simpler to start with.
The point of complication is that the site I'm adding it to extensively uses uSiteBuilder and I have to retain this. So document type properties are typically defined as something like:
What I'm curious about is what is the best thing to set as the public property for this document type, i.e. the public List< int > part above.
The site also extensively uses automapper so I will have to try and convert what is returned there into a usable object. Any advice appreciated also on how to best approach that.
Much obliged!
Hi John,
Well I never thought I'd hear about a combination of NC with uSiteBuilder! :-)
The return value type from NC is an
IEnumerable<IPublishedContent>
for multiple values, and anIPublishedContent
for a single value.uSiteBuilder should be able to wire that up.
Cheers, - Lee
You know me. Forever exploring the edge cases!
Damn (now I'll admit I'm not really a fan of uSiteBuilder) this throws a very annoying error.
I'll have to see what I can do.
If I do get the json as a string is there an easy way to convert it back to an IPublishedContent?
If the string is the serialised JSON, then it'll need to be ran through NC's value converter...
https://github.com/leekelleher/umbraco-nested-content/blob/master/src/Our.Umbraco.NestedContent/Converters/NestedContentValueConverter.cs
You'll need to create the
NestedContentValueConverter
object and callConvertDataToSource()
.I'm not sure where that code can run, it's been a long time since I've done uSiteBuilder.
Cheers,
- Lee
Thank you - that's perfect!
I'm using every dignified bone/nerve in my body to stop me saying sarcastic things about having to use usb here. I live in an idealistic universe where I hope by exposing them to the sheer goodness of NC it will broaden their horizons!
No I gave it a good hour, but couldn't get that to work there. The main issue is getting the PropertyType to pass through. Can't think of any good way of generically doing that, couldn't even quite find a way just to create one of the known correct type.
Anyway JArray has done the job nicely and happily works with automapper too!
Thank you again for pointing me in the right directions.
is working on a reply...