I have a widget which I'd like to hook into the save event for. As far as I can tell, the ContentSavedService event only returns the Content object for the page as a whole, and I then have to dig into Properties, grab the Value and parse the resulting JSON. This, and in particular, the JSON parsing, seems extremely unideal.
Is there a way to easily get an array/list of widgets on the page being saved so that I can find the one I'm trying to hook into? Or alternatively, a different way of hooking into the save event?
Are you doing this through angular or through C# class? I usually create a class that inherits from ApplicationEventHandler and then override the ApplicationStarted method:
protected override void ApplicationStarted(UmbracoApplicationBase umbracoApplication, ApplicationContext applicationContext)
{
Umbraco.Core.Services.ContentService.Saved += (sender, args) =>
{
foreach (var item in args.SavedEntities)
{
//find property and do something
}
};
}
As I understand it, the Saved event holds an IEnumerable of IContent objects that are being saved. From there, you can sift down to the property you need. No need to parse JSON, unless I'm misunderstanding your question?
Hooking into Save Events
I have a widget which I'd like to hook into the save event for. As far as I can tell, the ContentSavedService event only returns the Content object for the page as a whole, and I then have to dig into Properties, grab the Value and parse the resulting JSON. This, and in particular, the JSON parsing, seems extremely unideal.
Is there a way to easily get an array/list of widgets on the page being saved so that I can find the one I'm trying to hook into? Or alternatively, a different way of hooking into the save event?
Are you doing this through angular or through C# class? I usually create a class that inherits from ApplicationEventHandler and then override the ApplicationStarted method:
As I understand it, the Saved event holds an IEnumerable of IContent objects that are being saved. From there, you can sift down to the property you need. No need to parse JSON, unless I'm misunderstanding your question?
is working on a reply...