I'd like to run an event when the ExpireDate is reached ("Remove at" on the properties tab)
I'd like to Move the node to another branch and re-publish it there. But I cannot find such an event to use, I tried BeforeUnPublish but that event is only fired when manually clicking the unpublish button.
Background: The we have competition nodes. When a competition closes it is removed from the main listing. At some it will have competition winners added by an administrator. Closed competitions are displayed on a sidebar with thier associated list of winners. We want to seperate current and closed competitions in the admin to make it less cluttered and easier to use.
So... I guess I could put the move and republish on another event if I can get roughly the same outcome. (any suggestions?)
Or some other form of scheduling would also have the same effect.
I have not tried it but you might well find that the BeforeUnPublish event also fires if you Unpublish a page via the API, but if you are going to code this using the API, you might as well do the actual moving in your triggered code.
I needed to perform a similar thing and I found some info (unfortunately can't remember where) that suggested using an action handler instead. I ended up using this code. I think that if a class implements IActionHandler Umbraco will automatically recognise this and will call it as needed. This works when it is automatically expired.
namespace YourNamespace.ActionHandlers {
public class UnPublishActionHandler : umbraco.BusinessLogic.Actions.IActionHandler {
#region IActionHandler Members
public bool Execute(Document sender, umbraco.interfaces.IAction action) { //have to use the action handler rather than unpublish event because the event doesn't get called when a document //is being automatically expired (unpublished) if (action.Alias == umbraco.BusinessLogic.Actions.ActionUnPublish.Instance.Alias) {
//DO SOMETHING HERE
} return true; }
public string HandlerName() { return "YourNamespace.ActionHandlers.UnPublishActionHandler"; }
public umbraco.interfaces.IAction[] ReturnActions() { return new umbraco.interfaces.IAction[] { umbraco.BusinessLogic.Actions.ActionUnPublish.Instance }; }
Remove at aka ExpireDate event
Hi All
I'd like to run an event when the ExpireDate is reached ("Remove at" on the properties tab)
I'd like to Move the node to another branch and re-publish it there. But I cannot find such an event to use, I tried BeforeUnPublish but that event is only fired when manually clicking the unpublish button.
Background: The we have competition nodes. When a competition closes it is removed from the main listing. At some it will have competition winners added by an administrator. Closed competitions are displayed on a sidebar with thier associated list of winners. We want to seperate current and closed competitions in the admin to make it less cluttered and easier to use.
So... I guess I could put the move and republish on another event if I can get roughly the same outcome. (any suggestions?)
Cheers.
Murray.
Hi Murray,
One option you have is to schedule a task that checks for documents that have expired and move them using the API.
You can schedule tasks using Umbraco, although not 100% reliable it mentions on this page:
http://our.umbraco.org/wiki/reference/files-and-folders/files-in-the-config-folder/umbracosettingsconfig
Or some other form of scheduling would also have the same effect.
I have not tried it but you might well find that the BeforeUnPublish event also fires if you Unpublish a page via the API, but if you are going to code this using the API, you might as well do the actual moving in your triggered code.
Cheers,
Chris
Murray,
I needed to perform a similar thing and I found some info (unfortunately can't remember where) that suggested using an action handler instead. I ended up using this code. I think that if a class implements IActionHandler Umbraco will automatically recognise this and will call it as needed. This works when it is automatically expired.
Hope this helps,
Cheers,
Brian.
is working on a reply...