ModuleBuilder - Events (such as OnCreate or OnUpdate)
I have written a module using the Module Builder. It has a Content Type called "Slide". I have written a widget that creates a slideshow for a homepage using a jQuery script to loop through the Slides with nice effects (it's a fancier Rad Rotator). That works wonderful.
However, on the back-end in the create/edit screens, we need to re-order the slides when we want to feature a new slide in the #1 spot. I would like to do one of two things:
1. Override the default Create method so I can call that base functionality PLUS update all other Slides On Create, or
2. Add an event trigger that will serve as a callback command after a create, update, or delete event for a Slide.
Peace,
Brian
Hello Brian,
I suggest you subscribe for the IDataEvent, which is fired for Create, Update, Delete of content items. You should add the following code snippet to your Global.asax file:
protected
void
Application_Start(
object
sender, EventArgs e)
Telerik.Sitefinity.Abstractions.Bootstrapper.Initialized +=
new
EventHandler<Telerik.Sitefinity.Data.ExecutedEventArgs>(Bootstrapper_Initialized);
void
Bootstrapper_Initialized(
object
sender, Telerik.Sitefinity.Data.ExecutedEventArgs e)
if
(e.CommandName ==
"Bootstrapped"
)
EventHub.Subscribe<IDataEvent>(Content_Action);
private
void
Content_Action(IDataEvent @
event
)
var action = @
event
.Action;
var contentType = @
event
.ItemType;
var itemId = @
event
.ItemId;
var providerName = @
event
.ProviderName;
var manager = ManagerBase.GetMappedManager(contentType, providerName);
var item = manager.GetItemOrDefault(contentType, itemId);