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

Forums / Developing with Sitefinity / Add logic when user post a blog post in back-end

Add logic when user post a blog post in back-end

4 posts, 0 answered
  1. Nghi
    Nghi avatar
    8 posts
    Registered:
    05 Apr 2016
    06 May
    Link to this post

    So i want to catch an event occurs when a back-end user posts a blog post.

     

    Is there any possible way to do that?

     

     

  2. Dimitri Cools
    Dimitri Cools avatar
    80 posts
    Registered:
    08 Dec 2016
    10 May
    Link to this post
    Hello,

    You can use the IDataEvent from the EventHub and check for the item type - whether it is a blog item - this will be called on every operation.

    Please consult following documentation for additional information:
    http://docs.sitefinity.com/for-developers-idataevent

    eg.
    private void Content_Action(IDataEvent @event)
    {
        var action = @event.Action;
        var contentType = @event.ItemType;
        if (contentType == TypeResolutionService.ResolveType("Telerik.Sitefinity.Blogs.Model.BlogPost"))
        {
            // do something
            var itemId = @event.ItemId;
            var providerName = @event.ProviderName;
            var manager = ManagerBase.GetMappedManager(contentType, providerName);
            var item = manager.GetItemOrDefault(contentType, itemId);
        }
    }

    Regards,
    Dimitri Cools
    Telerik
     
    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 Sitefinity CMS Ideas&Feedback Portal and vote to affect the priority of the items
     
  3. Anand
    Anand avatar
    3 posts
    Registered:
    28 Mar 2016
    13 Jul
    Link to this post
    I have used the same for accessing & for enhance some of the custom functionality of blogpost, for that I have define some custom fields inside the blogposts so how can I access the data of this custom fields.
  4. Svetoslav Manchev
    Svetoslav Manchev avatar
    735 posts
    Registered:
    07 Dec 2016
    18 Jul
    Link to this post
    Hello Anand,

    Once you get the blogpost, you can manage the custom field you need, as described in the sample here:
    http://docs.sitefinity.com/for-developers-set-the-value-of-a-custom-field

    Regards,
    Svetoslav Manchev
    Telerik by Progress
     
    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 Sitefinity CMS Ideas&Feedback Portal and vote to affect the priority of the items
     
4 posts, 0 answered