ActionNew() - Obsolete. A public constructor exists ONLY for backwards compatibility in regards to 3rd party add-ons. All Umbraco assemblies should use the singleton instantiation (this.Instance) When this applicatio is refactored, this constuctor should be made private.
Does this mean that the example from the umbraco book is only for Umbraco 3? Will it work in Umbraco 4? How do I modify the example to use singleton instantiantion instead? This is not something I'm familiar with.
Thanks for replying! I actually sorted it out myself. The code looks like this:
using System; using System.Collections.Generic; using System.Text; using umbraco.BusinessLogic; using umbraco.cms.businesslogic.web;
namespace Karnhuset { public class UmbracoNaviHideToTrue : ApplicationBase { public UmbracoNaviHideToTrue() { Document.BeforePublish += new Document.PublishEventHandler(Document_SetUmbracoNaviHideToTrue); }
void Document_SetUmbracoNaviHideToTrue(Document sender, umbraco.cms.businesslogic.PublishEventArgs e) { // Log the event Log.Add(LogTypes.Custom, sender.Id, "Document_SetUmbracoNaviHideToTrue executed in UmbracoNaviHideToTrue");
// If it's a press release, set umbracoNaviHide to true if (sender.ContentType.Alias == "PressmeddelandeDoctype") { sender.getProperty("umbracoNaviHide").Value = 1; sender.Save(); } } } }
Correct me if I'm wrong, but I think that what was called "Action handlers" in Umbraco v3 and older was renamed "Event handlers" in Umbraco v4. Is this correct?
Implementing an action handler in Umbraco 4 - ActionNew() is obsolete?
Hi!
I've been looking at the umbraco book (http://umbraco.org/documentation/books/creating-and-using-an-action-handler) when trying to create my first action handler for Umbraco. My action handler should set umbracoNaviHide to true for a certain doctype, when a page with that type is published.
When i work with the code in Visual Studio it says that ActionNew() is deprecated. Reading this page: http://umbraco.org/apiDocs/html/AllMembers_T_umbraco_BusinessLogic_Actions_ActionNew.htm. I quote:
Does this mean that the example from the umbraco book is only for Umbraco 3? Will it work in Umbraco 4? How do I modify the example to use singleton instantiantion instead? This is not something I'm familiar with.
Regards,
Thomas Kahn
does this help.
Hi Anthony!
Thanks for replying! I actually sorted it out myself. The code looks like this:
Correct me if I'm wrong, but I think that what was called "Action handlers" in Umbraco v3 and older was renamed "Event handlers" in Umbraco v4. Is this correct?
/Thomas
Yup, v3 = action handlers, v4 = event handlers!
Cheers,
/Dirk
Thanks for sorting that out Dirk!
I've been out of the Umbraco loop for a while and need to brush up on my knowledge of v4.
Comment author was deleted
action handlers are still possible in v4, but v4 also has a rich event model (action handlers are limited to content, event model isn't, http://our.umbraco.org/wiki/reference/api-cheatsheet/using-applicationbase-to-register-events/overview-of-all-events )
is working on a reply...