This project is read-only.

Best place to intercept and modify content item

Topics: Customizing Orchard, General, Writing modules
Apr 22, 2015 at 11:34 AM
Edited Apr 22, 2015 at 3:03 PM
I was having a bit of a debate with a colleague at work and wondered if anybody could offer some input.

I need to intercept a content item when it is created (a 'prize' with a daily available count) and update a field programmatically (init the 'number left today').

My opinion was that the most appropriate place to do this is in the 'PrizePart' handler, using the 'OnPublishing' or 'OnUpdated' lifecycle hook.

My colleague thinks the best place is in the Driver post-back.

Can anybody offer a reason to pick one over the other?

Apr 22, 2015 at 7:48 PM
The handler is better suited as it will always be called, even from code invocation. The Driver usually contains methods that are only called from UI. However all the OnXXXX of a handler are also available in the Driver. The convention is to use a Part handler, so I would personally choose this one.
Apr 23, 2015 at 9:26 AM
Cheers Sebastien, that's really useful :) I'm just really digging in to Orchard properly and I am enjoying it a lot. Thanks to you and the team for all the work you put in.

Kind Regards,