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

Forums / Developing with Sitefinity / Preview mode does not show draft content

Preview mode does not show draft content

12 posts, 0 answered
  1. Bart Welch
    Bart Welch avatar
    64 posts
    Registered:
    10 Jul 2009
    23 Jun 2010
    Link to this post
    Is there a way to show the content that has been saved as Draft status on pages when you click "Preview"?

    Or is there another way to have non-devolers review multiple pages without having to click "edit" prior to publishing?
  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    24 Jun 2010
    Link to this post
    Hi Bart Welch,

    You can show the Draf version or another version of a content item in preview mode. You have to create a custom control that is bound to the content items you want to show. Inside your custom control you should check whether you have this QueryString - cmspagemode=preview. If cmspagemode=preview then you can get the Staged version of your content items. You can use ContentStatus enum of Telerik.Cms.Engine.

    StagedContent stg = manager.GetCurrentState(content.ID, true, true);
    if (stg != null)
    {
     switch (stg.Status)
             {
               case ContentStatus.Draft:
               break;
     
               case ContentStatus.Published:
               break;
     
             }
    }

     Finally you have to bind  the control you are going to use to the proper data source.

    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
  3. Shawn
    Shawn avatar
    79 posts
    Registered:
    26 Sep 2012
    22 Sep 2010
    Link to this post
    I have the same problem...and I don't completely understand the solution proposed by Telerik.  My end users would like to see what a piece of content looks like on the site without approving/publishing it.  Here's a specific use case.

    I have a published piece of Generic Content on my published homepage.  I make change to the Generic Content and click "Save".  The content is now in Draft mode.  I would like to "preview" what the content looks like on the site.  I click Page -> Home and the published version of the content appears.  However, I would like to see what the content looks like on the site before approving and publishing it.  Is there a way to accomplish this?  Essentially, I would like to view "Draft" content when the page is in preview mode. 

    The generic content is a bad example but a better use case would be with events or news where you have a "News" page that just displays a list of news in a specific category.  When you create a new news article you want to see what it looks like live on the site without publishing it.  Currently, I don't know of a way to preview content in the context of the site/page it resides on.
  4. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    23 Sep 2010
    Link to this post
    Hello Shawn,

    As we suggested, you need a custom control to do this and get the certain version of the content item "you can get the Staged version of your content items. You can use ContentStatus enum of Telerik.Cms.Engine."
    The code snippet shows how you can check for a given version of your item.

    By default GenericContent control has a property UseStagedVersion. When this property is "True" the control shows staged version - Draft, For Approval, Approved. If the property is false you will see only Published version

    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. Shawn
    Shawn avatar
    79 posts
    Registered:
    26 Sep 2012
    30 Sep 2010
    Link to this post
    Thanks for the response Ivan.  I might not have been direct in my question.  A page has 3 modes: live, preview, and edit. 

    Live: What the world see
    Preview (cmspagemode=preview): Shows what a page would look like if published (e.g. "Published" content on a "Draft" page)
    Edit (cmspagemode=edit): Shows the desired state of the page (e.g. "Draft" content on a "Draft" page with edit controls)

    It seems like there is a mode missing...something like cmspagemode=draft.  This mode would display draft content on a draft page without the edit controls.  Is there a way to do this?
  6. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    04 Oct 2010
    Link to this post
    Hello Shawn,

    You can have draft version of a page when you use workflow, but again this is a staged version of a  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
  7. Shawn
    Shawn avatar
    79 posts
    Registered:
    26 Sep 2012
    04 Oct 2010
    Link to this post
    Yes, you can have a draft version of a page.  However, the draft version still displays "published" content.  I would like to preview "draft" content on a page without the "edit" controls.  Currently, the only way to view "draft" content on a page is when a page is in edit mode.  I have end users that would like to view "draft" content as it would appear on a page...without displaying the edit mode controls that also get displayed in edit mode. 


    Here's a specific use case.

    1.  The home page is "published" and contains a piece of "published" generic content.
    2.  I edit the generic content putting it in "draft" status
    3.  I click "preview" on the home page and the old version of the content is displayed. This behavior is what I would expect.
    4.  I click "edit" on the home page and the new version of the content is displayed.  I would like to view the home page and the content without the edit mode controls that are also displayed in edit mode. 

    I would wondering if there is a "mode" that I'm not familiar with that will accomplish this functionality?
  8. Radoslav Georgiev
    Radoslav Georgiev avatar
    3370 posts
    Registered:
    01 Feb 2016
    05 Oct 2010
    Link to this post
    Hi Shawn,

    This scenario is not supported by default.

    What you have to do is to extend the Generic Content control as in this KB article. Then you would have to check the current page mode and if the page is in preview or admin mode you have to get the staged version of the content item as Ivan has described in one of his above posts. You can check the page mode using the code bellow:
    Telerik.Cms.Web.CmsPageBase cmsPage = this.Page as Telerik.Cms.Web.CmsPageBase;
    if (cmsPage.PageMode == Telerik.Cms.Web.CmsPageMode.Preview || cmsPage.PageMode == Telerik.Cms.Web.CmsPageMode.Admin)
    {
     
    }


    Kind regards,
    Radoslav Georgiev
    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
  9. Shawn
    Shawn avatar
    79 posts
    Registered:
    26 Sep 2012
    20 Oct 2010
    Link to this post
    How would this work across all modules?  Generic Content, Events, News, custom modules, etc.  I want to display the draft view across the board. 

    Can't I inherit from Telerik.Cms.Web.PreviewPage, change the class the Sitefinity/Admin/PreviewPage.aspx inherits from and override a method?  Maybe I can change PageMode to "Edit" and it will render the page as it would in edit mode but without the edit mode controls???

    We have a number of Sitefinity licenses.  Should I open a support ticket?
  10. Radoslav Georgiev
    Radoslav Georgiev avatar
    3370 posts
    Registered:
    01 Feb 2016
    27 Oct 2010
    Link to this post
    Hi Shawn,

    Unfortunately this cannot be done in the suggested way. You can override the PreviewPage class and override the PageMode property to be always edit:
    using System;
    using Telerik.Cms.Web;
     
    /// <summary>
    /// Summary description for CustomPreviewPage
    /// </summary>
    public class CustomPreviewPage: PreviewPage
    {
        public override CmsPageMode PageMode
        {
            get
            {
                return CmsPageMode.Edit;
            }
        }
        protected override void OnInit(EventArgs e)
        {
             
            base.OnInit(e);
        }
    }

    And then replace the built in one (~/Sitefinity/Admin/PreviewPage):
    <%@ Page Inherits="CustomPreviewPage, App_Code" MasterPageFile="~/Sitefinity/Dummy.master" %>

    However this will not change the behavior of the controls and you will still need to apply the previously suggested.

    Sincerely yours,
    Radoslav Georgiev
    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
  11. Shawn
    Shawn avatar
    79 posts
    Registered:
    26 Sep 2012
    27 Oct 2010
    Link to this post
    How will this work in 4.0?  Will users be able to preview content on the site prior to going live? 
  12. Radoslav Georgiev
    Radoslav Georgiev avatar
    3370 posts
    Registered:
    01 Feb 2016
    27 Oct 2010
    Link to this post
    Hi Shawn,

    The design of the preview functionality is pretty much the same in Sitefinity 4.0. In preview mode of the page you will see how the page looks like in live.

    Best wishes,
    Radoslav Georgiev
    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
Register for webinar
12 posts, 0 answered