Copied to clipboard

Flag this post as spam?

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


  • Topic author was deleted

    Apr 22, 2013 @ 15:06

    Custom Preview Suggestions

    Ok, here is the problem.

    I have a tree of content data that can be display 1 of 4 different ways (each way represents a region in the world).

    Therefore a piece of content cannot have a singular template as the template can change based on region.

    I have successfully developed a way to show each single piece of content the four different ways.

    However, preview is a bit of a nasty piece of the puzzle.

    I have had to disable 'normal' preview for each individual content since it assumes you want to preview the piece of content with it's selected template.

    What I really need is a way to take a Node; generate it's preview xml and marry it with a template of my choosing.

    Is there a way I can set the value of '$currentPage' before the macro's render?

    I can connect the rest of the dots after that.

    I have tried to reverse engineer the Preview class in the core:

    public partial class Preview : UmbracoEnsuredPage
    {
    protected void Page_Load(object sender, EventArgs e)
    {

    Document d = new Document(int.Parse(helper.Request("id")));

    PreviewContent pc = new PreviewContent(base.getUser(), Guid.NewGuid(), false);
    pc.PrepareDocument(base.getUser(), d, true);
    pc.SavePreviewSet();
    docLit.Text = d.Text;
    changeSetUrl.Text = pc.PreviewsetPath;
    pc.ActivatePreviewCookie();
    Response.Redirect("../../" + d.Id.ToString() + ".aspx", true);
    }
    }

    But I'm not sure that is the right path to head down.

     

  • Comment author was deleted

    Apr 22, 2013 @ 15:24

    This looked promising, but the class is marked internal so I cannot extend it.

    http://umbraco.codeplex.com/SourceControl/changeset/view/0420f4d89d14#src/Umbraco.Web/Templates/TemplateRenderer.cs

  • Comment author was deleted

    Apr 22, 2013 @ 16:51

    Ok, I've come up with a new strategy.

    I will be creating a temporary document, set all the templates, copy the data from the node to be previewed, etc; publish it to the cache; then redirect to it.  I know this will make it publicly available, but I will add it controls to make it non-guessable.

Please Sign in or register to post replies

Write your reply to:

Draft