Hi,
I'm trying to create an actionhandler that catches more actions (create, save, publish)
I made a property to show "debuginfo" during development. It looks like only the create event fires.
Any ideas?
Part of the code - just as a proof of concept:
[code]using umbraco.BusinessLogic.Actions;
using umbraco.BusinessLogic.console;
using umbraco.cms.businesslogic.web;
...
public umbraco.interfaces.IAction[] ReturnActions()
{
return new umbraco.interfaces.IAction[] {
new umbraco.BusinessLogic.Actions.ActionNew(),
new umbraco.BusinessLogic.Actions.ActionSave(),
new umbraco.BusinessLogic.Actions.ActionPublish()};
}
...
public bool Execute(Document documentObject, umbraco.interfaces.IAction action)
{
string myAction = action.Alias;
documentObject.getProperty("debuginfo").Value += myAction+" -";
return true;
}
[/code]
If you are using V4 of Umbraco it's good to know that action handlers are depricated. Events are the prefered way for V4. This document tells you how to create a class that can subscribe to eventsIt's possible to subscribe to more than 1 event so that should work for you. I have written a pdf with of all the umbraco 4.0.1 events. I've also written a blogpost with a few examples.
Actionhandler to catch more than one action?
Hi,
I'm trying to create an actionhandler that catches more actions (create, save, publish)
I made a property to show "debuginfo" during development. It looks like only the create event fires.
Any ideas?
Part of the code - just as a proof of concept:
[code]using umbraco.BusinessLogic.Actions;
using umbraco.BusinessLogic.console;
using umbraco.cms.businesslogic.web;
...
public umbraco.interfaces.IAction[] ReturnActions()
{
return new umbraco.interfaces.IAction[] {
new umbraco.BusinessLogic.Actions.ActionNew(),
new umbraco.BusinessLogic.Actions.ActionSave(),
new umbraco.BusinessLogic.Actions.ActionPublish()};
}
...
public bool Execute(Document documentObject, umbraco.interfaces.IAction action)
{
string myAction = action.Alias;
documentObject.getProperty("debuginfo").Value += myAction+" -";
return true;
}
[/code]
Hi,
If you are using V4 of Umbraco it's good to know that action handlers are depricated. Events are the prefered way for V4. This document tells you how to create a class that can subscribe to eventsIt's possible to subscribe to more than 1 event so that should work for you. I have written a pdf with of all the umbraco 4.0.1 events. I've also written a blogpost with a few examples.
Hope this helps you,
Richard
is working on a reply...