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

Forums / Developing with Sitefinity / Publish event issue

Publish event issue

6 posts, 1 answered
  1. Raghu
    Raghu avatar
    19 posts
    Registered:
    21 Jun 2010
    30 Nov 2010
    Link to this post


    We have a requirement where we want to capture every details of the page such as its contents, permissions etc and put it into xml file every time page is published.

     

    To achieve this we have following events captured in global.asx file where we can write code to save details in xml file.


     

    Telerik.Cms.CmsManager.Executing += new EventHandler<Telerik.ExecutingEventArgs>(CmsManager_Executing);
        
    Telerik.Cms.CmsManager.Executed += new EventHandler<Telerik.ExecutedEventArgs>(CmsManager_Executed);   
    //fails to capture  contents in first call but get the content of the page in second call during the same publishing event

     

     

    The issue with CmsManager_Executing event is that newly added contents just before publishing the page are not available. Basically Page’s control collection do now show controls just recently added to the page.

     

    If I decide to execute this code inside CmsManager_Executed event, I do get the recently added contents but this event is fired several times during the publishing of the page and it fails to capture contents in its very first call.

     

    Could you please suggest us the best way to carry out this kind of operations ?

     

    Thanks and Regards,

    Raghu

  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    30 Nov 2010
    Link to this post
    Hi Raghu,

    CmsManager_Executed is fired only once unless you do it somewhere explicitly. You can take a look at attached video.

    When you are changing pages permissions or other properties Executed and Executing events are not fired. You have to subscribe for Click event of save buttons in the templates for pages (Sitefinity/Admin/ControlTemplates/Pages)

    Greetings,
    Ivan Dimitrov
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  3. Raghu
    Raghu avatar
    19 posts
    Registered:
    21 Jun 2010
    30 Nov 2010
    Link to this post
    Hi Ivan ,

    Thanks for your quick response.

    I looked at video, but I want you to try this after addding 2-3 generic contents to the *newly created page* and then publish it.

    In my case when I perform this operation on newly created page, Executed event is fired 2 times, in first call the 

    e.CommandName 

    is set to Pulished and in the second call e.CommandName becomes PublishNew in the same publish event. But when I edit and publish already existing page then I do not see this issue.

    Thanks and Regards,
    Raghu

  4. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    30 Nov 2010
    Link to this post
    Hello Raghu,

    The sequence of the commands is

    1. Create Page
    2.Publish
    3.PublishNew

    Since there is a certain CommandName for each call you can use an if condition and use only PublishNew.

    Sincerely yours,
    Ivan Dimitrov
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  5. Raghu
    Raghu avatar
    19 posts
    Registered:
    21 Jun 2010
    30 Nov 2010
    Link to this post
    hi Ivan,

    Issue is that I am not able to retrieve any newly added contents in executed event when page is created first time.
    And PublishNew is only possible for newly created page (right ?). For any existing page when it is published, "PublishNew" is not coming into picture. Since PublishNew occurs only after Publish so how to check if the page being published will execute PublishNew or not ?

    Thanks,
    Raghu
  6. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    30 Nov 2010
    Link to this post
    Hello Raghu,

    I see what the problem is. The only way to get around this issue is using the page version as an identifier

    void CmsManager_Executed(object sender, Telerik.ExecutedEventArgs e)
    {
        var manager = new Telerik.Cms.CmsManager();
        var p = manager.GetPage(e.ItemID) as Telerik.Cms.ICmsPage;
        var v = p.Version;
    }

    When CommandName is Create Page the version is null. When CommandName  is Publish for the first time the version is 1. Each additional Publish  increase the version. So when you edit a page and publish it if the version is greater than 1 this means that this is not a new page.


    Best wishes,
    Ivan Dimitrov
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
    Answered
Register for webinar
6 posts, 1 answered