I have created a parameter type for nested content data types and it seems to be working fine. I am then struggling to actually get at the data from the nested content.
I can get nested content like: var images = Model.MacroParameters["Images"];
But I am then struggling to loop round each one and display the data.
Has anyone done this before?
Any help would be appreciated.
Cheers,
Jay
This is the data I get: [{"key":"0c189c8d-7d34-4996-88c4-0a7feb61851c","name":"Item 1","ncContentTypeAlias":"imageComposition","imageTitle":"Cumbrialife Food & Drink Awards","imageText":"Drinks producer of the year - finalist","image":"umb://media/af31ed4755da4948bde1f4aa1a949546"},{"key":"8066dfde-f97f-4412-9b1f-e022ddc4275e","name":"Item 2","ncContentTypeAlias":"imageComposition","imageTitle":"TEST","imageText":"TEST","image":"umb://media/af31ed4755da4948bde1f4aa1a949546"}]
Once I enabled Nested Content for use in Macro parameter type (using https://github.com/skttl/ParameterEditorGenerator), I couldn't use Model.GetParameterValue<IEnumerable<IPublishedContent>>("paramAlias") as it will always return null. This method doesn't support nonstandard macro data types like Nested Content.
I had to manually convert data sourse (JSON) using JsonConvert:
var accordionItemsSource = Model.MacroParameters["accordionItems"] as string;
var accordionItems = JsonConvert.DeserializeObject<List<dynamic>>(accordionItemsSource);
NestedContentPropertyValueConverters doesn't work here automatically, but I guess it works only with published content.
Here I found these embedded property converters that maybe can be used for conversion to IPublishedContent or IEnumerable
Nested Content as Macro Parameter
Hi,
I have created a parameter type for nested content data types and it seems to be working fine. I am then struggling to actually get at the data from the nested content.
I can get nested content like: var images = Model.MacroParameters["Images"];
But I am then struggling to loop round each one and display the data.
Has anyone done this before?
Any help would be appreciated.
Cheers, Jay
This is the data I get: [{"key":"0c189c8d-7d34-4996-88c4-0a7feb61851c","name":"Item 1","ncContentTypeAlias":"imageComposition","imageTitle":"Cumbrialife Food & Drink Awards","imageText":"Drinks producer of the year - finalist","image":"umb://media/af31ed4755da4948bde1f4aa1a949546"},{"key":"8066dfde-f97f-4412-9b1f-e022ddc4275e","name":"Item 2","ncContentTypeAlias":"imageComposition","imageTitle":"TEST","imageText":"TEST","image":"umb://media/af31ed4755da4948bde1f4aa1a949546"}]
I had the same situation.
Once I enabled Nested Content for use in Macro parameter type (using https://github.com/skttl/ParameterEditorGenerator), I couldn't use
Model.GetParameterValue<IEnumerable<IPublishedContent>>("paramAlias")
as it will always return null. This method doesn't support nonstandard macro data types like Nested Content.I had to manually convert data sourse (JSON) using
JsonConvert
:NestedContentPropertyValueConverters
doesn't work here automatically, but I guess it works only with published content.Here I found these embedded property converters that maybe can be used for conversion to IPublishedContent or IEnumerable
Hi Bojan,
Thank you for your reply. That's exactly what I ended up doing was converting the json to a model I could use.
Thank you for letting me know about the property converters. They look really useful so will have to give them a go.
Cheers, Jay
is working on a reply...