I'm using DocumentType.AfterSave to save a document type that has changed to the file system. However, when I use the sender object or get the document type by alias inside my AfterSave method, the changes haven't taken place. If I save again then I see the changes.
Is there something that I don't understand? Shouldn't the changes have taken place when the AfterSave event is dispatched?
Yeah I'll probably report it. It happens to two properties of which are allowedTemplates and DefaultTemplate.
I'm using Umbraco 4.7.1.1
Btw, is there anything else I can do to "fetch" the correct information? If I look at DocumentType class, it's calling base.Save() and then firing the AfterSave, so I'm wondering why this would happen at all because it "looks" correct in the class.
Could you provide a small code snippet? As you mention that in the AfterSave event you are trying to get the DocumentType by Alias... forgive my misunderstanding, wouldn't you already have access to the DocumentType object in the 'sender'?
Yes I do have reference to the DocumentType that is being saved which is the sender object. The changes to the DefaultTemplate and allowedTemplates have not taken place there.
Regarding DocumentType.GetByAlias, I was just trying to see if the changes have taken place there.
So if I check 3 templates in allowedTemplates and press save, then this function will log 0, if I save again it'll log 3. So it seems like the changes for the templates take place after the AfterSave trigger.
Just taken a look at the Umbraco core (v4.7.1.1) ... and you are right!
The page "~/umbraco/settings/EditNodeTypeNew.aspx" separates out the Allow/Default Template controls (and saving) from the rest of the DocumentType functionality, which is in a user-control "~/umbraco/controls/ContentTypeControlNew.ascx".
Since there are no hooks you can use to access the Allow/Default template on save, you might have to roll your own? My advice would be to take a look at Tom's Structure Extensions source-code (specifically the 'InjectExtensions.cs' code) ... try hooking into the "EditNodeTypeNew.aspx" page and attaching to the 'OnBubbleEvent'. It's a pretty wild idea, but might just work! ;-)
DocumentType.AfterSave
Hi.
I'm using DocumentType.AfterSave to save a document type that has changed to the file system. However, when I use the sender object or get the document type by alias inside my AfterSave method, the changes haven't taken place. If I save again then I see the changes.
Is there something that I don't understand? Shouldn't the changes have taken place when the AfterSave event is dispatched?
Thanks!
Upon further investigation it seems that allowedTemplates is the only one that doesn't change in the event, other variables are changing.
AfterSave should have updated all properties. I think this is a bug, could you report this on Codeplex?
Yeah I'll probably report it. It happens to two properties of which are allowedTemplates and DefaultTemplate.
I'm using Umbraco 4.7.1.1
Btw, is there anything else I can do to "fetch" the correct information? If I look at DocumentType class, it's calling base.Save() and then firing the AfterSave, so I'm wondering why this would happen at all because it "looks" correct in the class.
EDIT: I've added bug report to codeplex: http://umbraco.codeplex.com/workitem/30753
Hi Troska,
Could you provide a small code snippet? As you mention that in the AfterSave event you are trying to get the DocumentType by Alias... forgive my misunderstanding, wouldn't you already have access to the DocumentType object in the 'sender'?
Thanks, Lee.
@Lee Kelleher
Yes I do have reference to the DocumentType that is being saved which is the sender object. The changes to the DefaultTemplate and allowedTemplates have not taken place there.
Regarding DocumentType.GetByAlias, I was just trying to see if the changes have taken place there.
But basically this is my code snippet:
So if I check 3 templates in allowedTemplates and press save, then this function will log 0, if I save again it'll log 3. So it seems like the changes for the templates take place after the AfterSave trigger.
Hi Troska,
Just taken a look at the Umbraco core (v4.7.1.1) ... and you are right!
The page "~/umbraco/settings/EditNodeTypeNew.aspx" separates out the Allow/Default Template controls (and saving) from the rest of the DocumentType functionality, which is in a user-control "~/umbraco/controls/ContentTypeControlNew.ascx".
Since there are no hooks you can use to access the Allow/Default template on save, you might have to roll your own? My advice would be to take a look at Tom's Structure Extensions source-code (specifically the 'InjectExtensions.cs' code) ... try hooking into the "EditNodeTypeNew.aspx" page and attaching to the 'OnBubbleEvent'. It's a pretty wild idea, but might just work! ;-)
Cheers, Lee.
Yeah, I simply created my own class that inherits from EditContentTypeNew and made ContentTypeControlNew.ascx inherit my custom class.
So I just overrided OnBubbleEvent in my custom class and dispatched my own event there :)
Thanks for the help Lee Kelleher.
is working on a reply...