I have been testing the DataType events and I cant work out when they are suppose to fire. Heres my code:
using System; using umbraco.BusinessLogic; using umbraco.cms.businesslogic; using umbraco.cms.businesslogic.datatype;
public class Handlers : ApplicationBase { public Handlers(){ umbraco.cms.businesslogic.datatype.DataTypeDefinition.BeforeSave += new EventHandler<SaveEventArgs>(DataTypeDefinition_BeforeSave); umbraco.cms.businesslogic.datatype.DataTypeDefinition.New += new DataTypeDefinition.NewEventHandler(DataTypeDefinition_New); umbraco.cms.businesslogic.datatype.DataTypeDefinition.Saving += new DataTypeDefinition.SaveEventHandler(DataTypeDefinition_Saving); umbraco.cms.businesslogic.datatype.DataTypeDefinition.Deleting += new DataTypeDefinition.DeleteEventHandler(DataTypeDefinition_Deleting); }
I had break points set on all the Log.Add() functions and the only one I could get to fire was the BeforeSave event but this only fired when I saved a DocumentType not DataType as I would expect. I couldn't get the New, Saving and Deleting events to fire.
I am trying to add some events to when a DataType is saved in the developer section. Anyone know what I can do?
The DataTypeDefinition has 7 events to tap into: AfterDelete, AfterMove, AfterNew, AfterSave, BeforeDelete, BeforeMove and BeforeSave. You can attach to them using
DataTypeDefinition.Event += new EventHandler<umbraco.cms.businesslogic.EventArgs>(object sender, umbraco.cms.businesslogic.EventArgs e);
The only difference in the code that you have posted and what I put in my original post is the namespace before the DataTypeDefinition. So to me they look exactly the same.
And even changing it to your code it seems as though the BeforeSave event is getting fired when I save a DocumentType not the DataType. I think there may be something else going on here I will have a look at the umbraco source and see if I can work out whats going on.
i've had the same issue - i have code firing for all other backoffice events on macros, documenttypes, stylesheets, templates... but not on the save events for DataTypes.
I have tried the diffrent types of constructor. - still no luck. I've browsed the umbraco source code, can't actually see how DataTypes are saved at all! - can see where prevalues are - can see where the status bubble is fired too.
DataTypes appear to be written diffrently in the source to all the other types - like they where written ages ago and haven't been updated to new methods since (hence the .Saving while everything else has .AfterSave )
DataType Events
Hi all,
I have been testing the DataType events and I cant work out when they are suppose to fire. Heres my code:
I had break points set on all the Log.Add() functions and the only one I could get to fire was the BeforeSave event but this only fired when I saved a DocumentType not DataType as I would expect. I couldn't get the New, Saving and Deleting events to fire.
I am trying to add some events to when a DataType is saved in the developer section. Anyone know what I can do?
Thanks
Ben
shouldn't the code in Handlers be more like
DataTypeDefinition.AfterNew +=new EventHandler(DataTypeDefinition_AfterNew);
DataTypeDefinition.BeforeDelete +=new EventHandler(DataTypeDefinition_BeforeDelete);
? That seems to work
Hi David thanks for the reply but I still can't get it to work for me.
The DataTypeDefinition.New event has started firing when I add a new DataType but none of the others do.
The event I really want is the BeforeSave but looking at my code I cannot understand where it's going wrong.
Thanks
Ben
The DataTypeDefinition has 7 events to tap into: AfterDelete, AfterMove, AfterNew, AfterSave, BeforeDelete, BeforeMove and BeforeSave. You can attach to them using
DataTypeDefinition.Event += new EventHandler<umbraco.cms.businesslogic.EventArgs>(object sender, umbraco.cms.businesslogic.EventArgs e);
so, for the BeforSave, it looks like this:
DataTypeDefinition.BeforeSave +=new EventHandler<umbraco.cms.businesslogic.SaveEventArgs>(DataTypeDefinition_BeforeSave);
Ok thanks again,
The only difference in the code that you have posted and what I put in my original post is the namespace before the DataTypeDefinition. So to me they look exactly the same.
And even changing it to your code it seems as though the BeforeSave event is getting fired when I save a DocumentType not the DataType. I think there may be something else going on here I will have a look at the umbraco source and see if I can work out whats going on.
Thanks for your help.
Ben
Does anyone know whether or not the BeforeSave event should fire when saving a DataType?
I'm using v4.7 and it doesn't seem to fire
Thanks
Ben
seems like im getting this problem too, anyone got a solution yet?
i've had the same issue - i have code firing for all other backoffice events on macros, documenttypes, stylesheets, templates... but not on the save events for DataTypes.
I have tried the diffrent types of constructor. - still no luck. I've browsed the umbraco source code, can't actually see how DataTypes are saved at all! - can see where prevalues are - can see where the status bubble is fired too.
DataTypes appear to be written diffrently in the source to all the other types - like they where written ages ago and haven't been updated to new methods since (hence the .Saving while everything else has .AfterSave )
anyway - I've logged a issue http://issues.umbraco.org/issue/U4-1781 ;
is working on a reply...