Get IEnumerable<IPublishedElement> from Nested Content Database Value
Hey,
I am messing around with some properties via the save event/content service in a V8 Component. And would like to access some data I have saved as a Nested Content datatype. Is there a way with IContent to access Nested Content data from within a converted object?
e.g. Deserialize the Nested Content Json to IEnumerable
I can't use the Umbraco Helper as the cache doesn't appear to have been updated at this point. (ContentService.Saved or ContentService.Saving) So to do it that way would require the editor to click publish twice.
I've tried, but this doesn't work:
var text = content.GetValue<string>("layoutContent");
JsonConvert.DeserializeObject<List<PublishedElement>>(text)
You cannot access any published content within the IContent.
What I would suggest is that you listen to the ContentCache.CacheUpdated, because now you can access the IPublishedContent and use it as you normally would.
Get IEnumerable<IPublishedElement> from Nested Content Database Value
Hey,
I am messing around with some properties via the save event/content service in a V8 Component. And would like to access some data I have saved as a Nested Content datatype. Is there a way with IContent to access Nested Content data from within a converted object?
e.g. Deserialize the Nested Content Json to IEnumerable
I can't use the Umbraco Helper as the cache doesn't appear to have been updated at this point. (ContentService.Saved or ContentService.Saving) So to do it that way would require the editor to click publish twice.
I've tried, but this doesn't work:
Cheers Ric
(for anyone who stumbles across this) I've achieved what i wanted to using
And then a series of null checks and subsequent deserialisation for nested nested. Works, but feels very v4 like.
I am having a hard time with this, because in v7 one could simply call
and it would work. Now, I'm having to use a very cumbersome
List<dynamic>
for everything.Is it possible to access
IEnumerable<IPublishedElement
> from within aIContent
object? Using theIContentService.GetById
method?This is becoming annoying really fast.
Hi Carlos.
You cannot access any published content within the IContent.
What I would suggest is that you listen to the ContentCache.CacheUpdated, because now you can access the IPublishedContent and use it as you normally would.
Hope it helps.
Perfect, that works! Thank you!
This has been resolved! Cannot set it as correct :(
is working on a reply...