System-wide events

Topics: Writing modules
Apr 2, 2012 at 12:18 PM

I want to execute some code in my module when a Page is published or a Widget is saved. What is the correct way to go about doing this?

Thanks

Developer
Apr 2, 2012 at 6:21 PM

Look at the On* methods of Handlers, you can use them to hook into event of content parts (which would be the most straightforward with WidgetPart I think) and into overriding the Published method of a Handler to attach events to any content type. So if you want to attach to a part, go with the On* methods (there you can also check for content type from the context object), and if to a type, go with the method overriding (where you can check for content type from the context object too).