Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Collin 42 posts 62 karma points
    Nov 03, 2011 @ 12:19
    Collin
    0

    Preview mode for Members

    The default behaviour of Umbraco is that preview mode can only be enabled if you are logged in as an user.

    However we would like to enable this for member logins of the site. As they also add (quite complex) content to the site that they need the ability to preview. As this content is quite complex, and contains a lot of properties, it's a lot of work to create our own preview mode for members.

    Is there a way we can extend the default umbraco preview mode so that members also have the ability to preview pages?

     

    Please note that I use "/umbraco/dialogs/preview.aspx?id=NodeId" to trigger the preview node. As members don't know the nodeid's of the pages of other members they cannot trigger it themselves.

  • Thomas 49 posts 78 karma points c-trib
    Nov 04, 2011 @ 12:43
    Thomas
    1

    Hi - had some fun with previews, might be of some use to you:

    • - When you click preview in the admin UI, Umbraco generates a clone of the XML from the node your previewing down, but of course with the difference of including the current unpublished node. You can see these files in the \app_data\previews folder.
      The files are named with a Guid, while you're in preview mode you will see that Guid in a cookie in your browser. When you click the end preview, the cookie is removed, but the file is left (note this causes us some problems as we have a 50MB content XML, so we have a scheduled task clearing these at midnight).
    • - One problem for your scenario is that Umbraco requires a User in the preview logic - but perhaps creating a new "PreviewUser" and use that globally wouuld work. Below is the source from the Umbraco Preview.aspx.cs - maybe try placing that on your own MemberPreview.aspx page and have a play with passing in a dedicated user:
            protected void Page_Load(object sender, EventArgs e)
            {
                Document d = new Document(int.Parse(helper.Request("id")));
                bool includeChildren = true; //  !String.IsNullOrEmpty(UmbracoContext.Current.Request["children"]) ? true : false;
                PreviewContent pc = new PreviewContent(Guid.NewGuid());
                pc.PrepareDocument(base.getUser(), d, includeChildren);
                pc.SavePreviewSet();
                docLit.Text = d.Text;
                changeSetUrl.Text = pc.PreviewsetPath;
                pc.ActivatePreviewCookie();
                Response.Redirect("../../" + d.Id.ToString() + ".aspx", true);
            }

     

    Also note that you can disable the "IncludeChildren" to generate a much smaller XML preview, and limit your members to only view the one page.  

    Let us know how you get on - would be a nice feature to have working! :0)

     

     

  • Collin 42 posts 62 karma points
    Nov 07, 2011 @ 10:01
    Collin
    0

    This would probably work if I implemented, although currently we have are using a different solution which isn't perfect but it works.

    So I hope I get the time to implement this.

Please Sign in or register to post replies

Write your reply to:

Draft