This project is read-only.

OnPublished not working? Need OnSaved?

Topics: Customizing Orchard, Troubleshooting, Writing modules
Jun 24, 2011 at 12:46 AM

I'm trying to use OnPublished in a handler that I'm using for some site settings, and it's not being called when I save the settings. I was expecting to find an OnSave method, but am using OnPublished as thats the only one kind of makes sense.  OnLoaded works...


OnPublished<MySettingsPart>((context, part) => { doSomething(part.MySetting); });

OnLoaded<MySettingsPart>((context, part) => { doSomething(part.MySetting); });

Jun 24, 2011 at 12:53 AM
Edited Jun 24, 2011 at 12:53 AM

What are those settings? If they are yours, acting in the driver should work. Also, there is nothing preventing the existence of more than one driver for the same part type.

Jun 24, 2011 at 12:56 AM

Yea those are my settings. I was using a Handler (and the OnPublished is in the constructor) and not a driver for the settings

Jun 24, 2011 at 12:58 AM

Can you try with a driver?

Jun 24, 2011 at 1:04 AM

How would i go about subscribing to that event from the driver?

Jun 24, 2011 at 1:08 AM

You don't need to subscribe to an event. In the editor method, after you've updated your stuff, you can do whatever you have to do.

Jun 24, 2011 at 8:12 PM

I went with a driver... How would I go about setting a default value that I would normally set with OnInitializing from a handler? (should i just still use OnInitializing in the handler to set it?)

Do i still need a content handler at all?

Jun 24, 2011 at 9:55 PM

Yep you should still have it, in fact you have to have it, to register the storage filter for your part.