Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Nik Wahlberg 639 posts 1237 karma points MVP
    Jul 24, 2009 @ 15:22
    Nik Wahlberg
    0

    Capturing Events

    Hi all,

    I am writing some event handlers in order to interact with the nodes in the Umbraco tree upon publishing (AfterPublish) and for some reason, my events don't seem to be caught. I added the class to a DLL and copied it to the bin folder, I am extending ApplicationBase and captuing the event like so:

    using umbraco.BusinessLogic;
    using umbraco.cms.businesslogic.web;
    using umbraco.cms.businesslogic.property;

    namespace DB.Utilities
    {
    class AutoWriteHPFeatureXml : ApplicationBase
    {
    // default constructor; call the event
    public AutoWriteHPFeatureXml()
    {
    Document.AfterPublish += new Document.PublishEventHandler(Document_AfterPublish);
    }

    void Document_AfterPublish(Document sender, umbraco.cms.businesslogic.PublishEventArgs e)
    {
    //Always LOG
    Log.Add(LogTypes.Custom, sender.Id, "Event raised");

    //Check if the doctype is news
    if (sender.ContentType.Alias == "Feature")
    {
    foreach (Document d in sender.Parent.Children)
    {
    string name = d.Text;
    Property p=d.getProperty("hpFeatureSort");
    }
    }
    }
    }
    }

    This example is from Richard (http://www.richardsoeteman.net/PermaLink,guid,f470b6cf-40da-4aa9-a0d9-7b984fe9bf59.aspx) which is a gret post and overview, but I think I must be missing something.

    Thanks for your help.

    -- Nik

  • Dirk De Grave 4541 posts 6021 karma points MVP 3x admin c-trib
    Jul 24, 2009 @ 15:34
    Dirk De Grave
    100

    Nik, your class must be public, otherwise the umbraco runtime cannot pick up your class using reflection!

     

    Cheers,

    /Dirk

     

  • Dirk De Grave 4541 posts 6021 karma points MVP 3x admin c-trib
    Jul 24, 2009 @ 15:36
    Dirk De Grave
    0

    Also, restart app (touching web.config or app pool restart)!

  • Nik Wahlberg 639 posts 1237 karma points MVP
    Jul 24, 2009 @ 16:41
    Nik Wahlberg
    0

    DOH! Sorry for the obvious question. Should have caught that one.

Please Sign in or register to post replies

Write your reply to:

Draft