Forums

Skip Navigation LinksHome / Developer Network / Forums / Sitefinity 3.x: Developing with Sitefinity > Page Rollback: From Draft to Previous Version

Page Rollback: From Draft to Previous Version

  • Posted on Mar 2, 2010 (permalink)

    Continuing on the progress we made in the previous post, the next step is reverting a page in a checked in, Draft state back to its previous version before changes were made

    I've spent several hours experimenting with no luck. The documentation offers no guidance. I'm wondering how you would approach it.

    We know that the VersionManager doesn't work on page items, however, Rodoslav mentioned a page "copy" method for 3.7 SP2. I'm running that version, if that method is useful.

    Thanks,
    Jeff

    Reply

  • Ivan Dimitrov Ivan Dimitrov admin's avatar

    Posted on Mar 2, 2010 (permalink)

    Hi Jeff,

    1. The forum post shows how to use VesionManager and working with object's versions.

    2. You can use the UI to perform Restore. Note that the highlighted button should be visible and not commented.

    <asp:GridView ID="GridView1" AllowPaging="true" PageSize="20" AutoGenerateColumns="false" GridLines="none" CssClass="listItems history" runat="server">
            <Columns>
                <asp:TemplateField>
                    <ItemTemplate>
                        <asp:HyperLink ID="PreviewLink" runat="server"><asp:Literal runat="server" Text="<%$Resources:View %>"></asp:Literal></asp:HyperLink
                        <asp:LinkButton ID="RollbackButton" runat="server"><asp:Literal runat="server" Text="<%$Resources:RollBack %>"></asp:Literal></asp:LinkButton>
                        <asp:LinkButton ID="RestoreButton" runat="server"><asp:Literal ID="Literal1" runat="server" Text="Restore"></asp:Literal></asp:LinkButton>
                    </ItemTemplate>
                    <ItemStyle CssClass="gridActions" />
                </asp:TemplateField>
                <asp:BoundField DataField="Version" HeaderText="<%$Resources:Version %>"><ItemStyle CssClass="gridContentTitle" /></asp:BoundField>
                <asp:BoundField DataField="Stamp" HeaderText="<%$Resources:Date %>" HeaderStyle-CssClass="GridHeader_SiteFinity" DataFormatString="<%$Resources:VersionDateFormat %>" HtmlEncode="false" />
                <asp:BoundField DataField="Modifier" HeaderText="<%$Resources:Author %>" HeaderStyle-CssClass="GridHeader_SiteFinity" />
                <asp:BoundField DataField="Theme" HeaderText="<%$Resources:Theme %>"><ItemStyle /></asp:BoundField>
            </Columns>
        </asp:GridView>

    programmatically restoring a page

    IStagedPage staged = this.iPage.GetVersion(version);
    staged = staged.CheckOut();
    staged.CheckIn();


    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.

    Reply

  • Posted on Mar 2, 2010 (permalink)

    Thanks for the quick response.

    Can I get a complete code sample? I'm not sure how to apply it since ICmsPage.Staged is a read-only property.

    Reply

  • Ivan Dimitrov Ivan Dimitrov admin's avatar

    Posted on Mar 3, 2010 (permalink)

    Hi Jeff,

    Below is a sample code that will do restore - a new version will be created( copy )

    // pass the page and its version to a private method
     
    private void Restore(int version, ICmsPage p)
    {
     
        IStagedPage staged = p.gGetVersion(version);
        staged = staged.CheckOut();
        staged.CheckIn();
        OnRestore(EventArgs.Empty);
    }


    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.

    Reply

  • Posted on Mar 11, 2010 (permalink)

    Hi Ivan,

    I'm back.

    The latest sample isn't working. No new version of the page is created and the current version is unchanged.

    Is there something in the "OnRestore" event that finishes the job? I'm not privy to what's in that event or how to call it.

    Thanks,
    Jeff

    Reply

  • Ivan Dimitrov Ivan Dimitrov admin's avatar

    Posted on Mar 12, 2010 (permalink)

    Hi Jeff,

    OnResote is used when the Grid is rebind. I slightly modified the code at my end and it is working correctly. It performs restore of version 3 for the specified page.

    var manager = new CmsManager();
    ICmsPage p = (ICmsPage)manager.GetPage(new Guid("797aa331-7edf-4dc1-9c92-80e8ccf12bcd"), true);
    IStagedPage s = p.GetVersion(3);
    IStagedPage st = s.CheckOut();
    st.CheckIn();


    Regards,
    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.

    Reply

  • Posted on Mar 12, 2010 (permalink)

    Ivan,

    You have given me the same code sample (from a functional standpoint) three times in a row. It doesn't work.

    Can you please test this out yourself so we don't keep going around in circles?

    Thanks,
    Jeff

    Reply

  • Ivan Dimitrov Ivan Dimitrov admin's avatar

    Posted on Mar 14, 2010 (permalink)

    Hello Jeff,

    I have tested the code several times. Take a look at the attached video prepared for your convenience. I am not sure why the code does not work for you. Note that this code restore - copy a page version by creating a new one.

    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.
    Attached files

    Reply

  • Posted on Mar 15, 2010 (permalink)

    I see that it is working for you and I appreciate that you even went through the trouble to produce a video. At this point, I guess we just need to figure out why I don't get the same results.

    I couldn't tell from the video if you have workflow enabled. If it is, I could not see the page status. In my case, I am trying to go from a "Draft" status to a previous version.

    Can you confirm that this code sample works under the same conditions for you?

    Also, I see you page "Rollback" and "Restore" links next to every version on the History page. I only have Roll back. Could this be factor? Does my lack of a Restore link mean there's a feature that I haven't enabled that could be preventing the code from working?

    Thanks for your continued efforts on this issue.

    Jeff

    Reply

  • Register for webinar
Skip Navigation LinksHome / Developer Network / Forums / Sitefinity 3.x: Developing with Sitefinity > Page Rollback: From Draft to Previous Version