+1-888-365-2779
Try Now
More in this section

Forums / Developing with Sitefinity / adding event handlers

adding event handlers

13 posts, 0 answered
  1. SelAromDotNet
    SelAromDotNet avatar
    912 posts
    Registered:
    18 Jul 2012
    18 Sep 2008
    Link to this post
    I'm not very experienced with this but I would like to learn more especially with relation to how it can be used in sitefinity...

    are external events raised by sitefinity and if so can we hook into them? for example, the events module's backend is locked down so I can't make any changes to how it works unless I inherit from it... but if it exposes events (such as oneventposting, oneventposted, oneventdeleted etc) I could add some additional functionality on my site (such as sending out notifications, invalidating manually created caches, etc)...

    if this is already available, can you kindly show me where to find it in the documentation? I didn't see anything about custom event handling of sitefinity events...

    if this isn't available I think it would be great to have! other cms products like blogengine make extensive use of this to allow external events to add functionality to the site. This would be really great to further enhance the extensibility of sitefinity...

    but then again like I said it might already be there and I just can't find it :)
    thanks!
  2. Gabe Sumner
    Gabe Sumner avatar
    440 posts
    Registered:
    09 Sep 2007
    20 Sep 2008
    Link to this post
    Hi SelArom,

    I'm learning along with you on this one.  You might check out Bob's post to this thread:

    http://www.sitefinity.com/support/forums/support-forum-thread/b1043S-bgbtbk.aspx

    In this example [if I'm understanding correctly] Bob is adding a custom UserControl to the Events ControlPanel Editor.  He is then attaching a new event "SaveButton_Command" to the existing Button. 

    So when a user clicks to "Save" for their event, we're able to execute some custom code. 

    I'm not sure if this is exactly what you're looking for, but I thought it might help.  Please let me know your thoughts.

    Gabe Sumner

  3. Ivan
    Ivan avatar
    478 posts
    Registered:
    16 Jun 2015
    22 Sep 2008
    Link to this post
    Hi SelArom,

    we do have application wide events, unfortunately we have not yet documented them very well. Here is a url to an article that explains this on a very high level:
    http://www.sitefinity.com/help/developer-manual/modules-api-overview.html

    Basically, every manager class will fire two events: OnExecuting and OnExecuted. As you may guess, OnExecuting takes place when action has been started, but not yet finished. OnExecuted is fired once the action has been completed.

    Here you can find more about the signatures of both events:
    http://www.sitefinity.com/help/developer-manual/telerik.framework-telerik.managerbase%601-onexecuted.html
    and
    http://www.sitefinity.com/help/developer-manual/telerik.framework-telerik.managerbase%601-onexecuting.html

    The important thing to note here are actually the two custom implementations of EventArgs,
    ExecutingEventArgshttp://www.sitefinity.com/help/developer-manual/telerik.framework-telerik.executingeventargs.html
    and
    ExecutedEventArgs http://www.sitefinity.com/help/developer-manual/telerik.framework-telerik.executedeventargs.html

    The important members of these EventArgs are CommandName and Data. So, for example for GC based modules (News, Events, Blogs, Libraries) the CommandName will be one of the three:
    - "CreateContent"
    - "SaveContent"
    - "DeleteContent"
    and Data object will be IContent object on which the command has been executed or is executing at the moment.

    I really do regret that we have not explained this indeed important topic in more detail. Let us know if there is anything else we can do for you. 

    All the best,
    Ivan
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
  4. Pierre
    Pierre avatar
    433 posts
    Registered:
    16 Feb 2006
    22 Sep 2008
    Link to this post
    Hi Ivan,

    Could you explain litle more about this plz. I have linked one codebehind in one GC module (news) to execute one action at Savebutton on click event (edit/insert modes). It's posible to execute this action at Onexecuted on SaveContent?. Could you found one exemple of class to extend the GC modules with new events like this,plz. Regards
  5. Kalina
    Kalina avatar
    176 posts
    Registered:
    27 Oct 2016
    25 Sep 2008
    Link to this post
    Hello Romi,

    Please, find the answers to your questions below:
    1) It's posible to execute this action at Onexecuted on SaveContent?
    Yes, we confirm that this is possible.
    2) Could you found one example of class to extend the GC modules with new events like this?
    Basically, you can use any of the available classes. The choice will depend on what exactly you want to achieve as desired behavior.

    Regards,
    Kalina
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
  6. sam
    sam avatar
    102 posts
    Registered:
    31 Jan 2008
    03 Jun 2009
    Link to this post
    Is there more information about this topic?

    I want to know when forum posts have been responded to the email all parties included in discussion.

    Also, email blog authors notifying them of comments added.

    This is very much appreciated..
  7. Georgi
    Georgi avatar
    3583 posts
    Registered:
    28 Oct 2016
    08 Jun 2009
    Link to this post
    Hi Sam,

    Please take a look at this:
     
        void Application_Start(object sender, EventArgs e)        
        {     
              Telerik.Forums.ForumManager.Executing += new EventHandler<Telerik.ExecutingEventArgs>(ForumManager_Executing);      
     
        }     
          
        void ForumManager_Executing(object sender, Telerik.ExecutingEventArgs e)      
        {     
            if (e.CommandName == "CreatePost")    
            {     
                Telerik.Forums.IPost item = e.CommandArguments as Telerik.Forums.IPost;       
     
                // item.Content ...       
     
                // item.Title     
                // item.SomeThingElse     
            }     
        }     
     

    The available events are:

    - CreateForum
    - DeleteForum
    - CreatePost
    - DeletePost
    - UpdatePost

    So you can choose the event you want and add the logic for it. I have already provided you with an answer in the other forum thread about the different users and their posts.

    Best wishes,
    Georgi
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
  8. sam
    sam avatar
    102 posts
    Registered:
    31 Jan 2008
    10 Jun 2009
    Link to this post
    hi,

    if these are the ones for forums:
    The available events are:

    - CreateForum
    - DeleteForum
    - CreatePost
    - DeletePost
    - UpdatePost

    What are the ones for blogs, news, events and page? And what are the event signatures?????
  9. Georgi
    Georgi avatar
    3583 posts
    Registered:
    28 Oct 2016
    12 Jun 2009
    Link to this post
    Hello Sam,

    Since the Generic Content, News, Blogs, Events, Images and Documents are all Generic Content based, we are using one manager class for them - the ContentManager class. Let me show you how you can subscribe to its Executing method:
     void Application_Start(object sender, EventArgs e)  
        { 
            // Code that runs on application startup 
            Telerik.Cms.Engine.ContentManager.Executing += new EventHandler<Telerik.ExecutingEventArgs>(ContentManager_Executing); 
        } 

    void ContentManager_Executing(object sender, Telerik.ExecutingEventArgs e) 
        { 
            //CommandName could be: 
            // CreateContent, 
            // UpdateContent, 
            // DeleteContent, 
            if (e.CommandName == "CreateConten"
            { 
                Telerik.Cms.Engine.IContent item = e.CommandArguments as Telerik.Cms.Engine.IContent; 
                //check the provider 
                //News,Generic_Content,Blogs,Libraries,Events and any other generic content based module provider,  
                //or an additional provider to any of the existing modules 
                if (item != null && item.ProviderName == "News"
                { 
                    string title = item.GetMetaData("Title").ToString(); 
                } 
                     
            } 
        } 

    Note that you use one manager, and just check the provider name in order to distinguish the different modules. In 4.0, most of the modules will be Generic Content based.

    Now about the pages. We are using the CmsManager:
    void Application_Start(object sender, EventArgs e)  
        { 
            // Code that runs on application startup 
            Telerik.Cms.CmsManager.Executing += new EventHandler<Telerik.ExecutingEventArgs>(CmsManager_Executing); 
            
        } 

    and the handler:
    void CmsManager_Executing(object sender, Telerik.ExecutingEventArgs e) 
        { 
            //CommandName for pages could be: 
            // CreatePage 
            // Publish 
            // DeletePage 
            if (e.CommandName == ""
            { 
                Telerik.Cms.IPage page = (Telerik.Cms.IPage)e.CommandArguments; 
            }; 
        } 

    Note that there is also Executed (rather than Executing) method of all the managers - Executing occurs before the action, while Executed is when the action is complete.

    Let me know if you need any further information.

    All the best,
    Georgi
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
  10. Romany
    Romany avatar
    8 posts
    Registered:
    19 Mar 2012
    25 Mar 2012
    Link to this post
    Hello Georgi,

    I am using verion 4.3, but the executed event with commaned name (ex: "CreateEvent") is called multiple times,
    1- how can I stop this ? because I am sending a notification email when new event created
    2- I need to send the URL for the new created event, from where can I get the URl for the newly created event

    Thanks
    Romany

  11. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    26 Mar 2012
    Link to this post
    Hello,

    You can override the data provider and its public methods that are called once where needed and then replace the default data provider through configurations.

    Greetings,
    Ivan Dimitrov
    the Telerik team
    Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  12. Romany
    Romany avatar
    8 posts
    Registered:
    19 Mar 2012
    26 Mar 2012
    Link to this post
    Hello Ivan,

    1- Please can you give me step by step with code, how to override the data provider for "News" to do the following job:when new item created send an email

    2- on the following event in "News" I need to get the new item created data but always all propoerties is empty, why this ?
    void Events_Executed(object sender, Telerik.ExecutedEventArgs e)
    {
    }


    Thanks,
    Romany
  13. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    28 Mar 2012
    Link to this post
    Hello,

    I send a reply to you here with samples and description about how to achieve your goal.

    Regards,
    Ivan Dimitrov
    the Telerik team
    Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Register for webinar
13 posts, 0 answered