Copied to clipboard

Flag this post as spam?

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


  • Tim 225 posts 690 karma points
    Jul 20, 2010 @ 19:19
    Tim
    0

    How is preview in 4.5 meant to work

    Hi,

    I've been experimenting with the new preview functionality in Umbraco and I'm a bit unclear as to what it should and shouldn't be doing.

    It seems to create a copy of the umbraco.config but with unpublished content in a preview directory.

    I'm assuming this contains all unpublished content and that the site uses that as the content cache when in preview mode. If this is the case then anything like XSLT macros and nodefactory calls should get the latest unpublished content.

    However I've noticed in my testing that this is not the case... or doesn't appear to be

    My macros always seem to pull back published content. I'm using Linq2Umbraco extensively and wonder if this is part of the problem?

    Or perhaps I need to modify my macros to check for preview mode and do something different if this is the case?

    I can't seem to find any clear documentation on how this is meant to work so any pointers would be much appreciated.

    T

     

  • Warren Buckley 2106 posts 4836 karma points MVP ∞ admin hq c-trib
    Jul 20, 2010 @ 19:24
    Warren Buckley
    0

    Hiya Tim,
    As your not using XSLT it won't be using the other XML cache file, as I have yet to really touch Linq2Umbraco I wouldn't be able to say, but like you said I think this could be part of the problem that Linq2Umbraco only works against live/published data and not this unpublished data.

    Try an easy XSLT macro in a page where you expect to see unpublished content and see if it is all working OK with XSLT. If it is then you can elimante the problem and say it's down to Linq2Umbraco and then worth getting in touch with Mr Linq2Umbraco (Aaron Powell - @slace)

    Warren :)

  • Tim 225 posts 690 karma points
    Jul 20, 2010 @ 19:49
    Tim
    0

    Further testing has revealed that Nodefactory also doesn't seem to pull content from the preview XML.

    hmmm....

    T

  • Warren Buckley 2106 posts 4836 karma points MVP ∞ admin hq c-trib
    Jul 20, 2010 @ 19:56
    Warren Buckley
    0

    OK interesting to know, but did XSLT work?

    Warren

  • Tim 225 posts 690 karma points
    Jul 20, 2010 @ 20:14
    Tim
    0

    Unfortunately I need programmatic access to the nodes. I'll give pure XSLT a go when I get 5 mins (unless you want to ;-) )

    Looks like I'll need a way to tell my code it's in preview mode and grab the nodes from the preview nodes xml. With Linq2Umbraco I think you can define the XML file you want to use so should be possible, but I could also do with Nodefactory access to the preview content....

    T

  • Niels Hartvig 1951 posts 2391 karma points c-trib
    Jul 20, 2010 @ 20:24
    Niels Hartvig
    3

    Preview should work with XSLT, NodeFactory and LINQ2Umbraco (in other words everything), but be aware that preview works with the node you're previewing and any sub nodes:

    A
    - B <= PREVIEW BUTTON CLICKED
    -- B1
    -- B2
    ---- B2.1
    - C
    - D

    In the case above it would take the non published content from B, B1, B2 AND B2,1 but the published content from A, C and D (for performance). If you want to browse the whole site in preview you'd need to click the top level node (A). Notice that preview mode is ONLY active when the preview banner is visible. Preview mode gets disabled the moment you go edit another page (to avoid confusion).

    Hope this helps!

  • Tim 225 posts 690 karma points
    Jul 20, 2010 @ 20:55
    Tim
    0

    So to be clear.

    If I start browsing the site in preview mode but start from the root node. ALL site content will be in preview mode (even if I navigate to another page from the preview page)

    And if I start previewing from a sub node all sub pages will be in preview mode but not siblings or parents etc. Thanks

    T

  • Niels Hartvig 1951 posts 2391 karma points c-trib
    Jul 20, 2010 @ 20:56
    Niels Hartvig
    0

    Yup.

  • Tim 225 posts 690 karma points
    Jul 20, 2010 @ 21:05
    Tim
    0

    Cool! Umbraco rocks!

  • Tim 225 posts 690 karma points
    Jul 21, 2010 @ 19:50
    Tim
    0

    Hi,

    I've done extensive tsing now on the new Preview functionality and it works as advertised except for Linq2Umbraco which is not compatible currently with the new preview.

    It always uses the current published content. Not sure how tricky it will be to change it to work with the new preview model.

    As it expects a path to the content XML (it's currently getting it from here: UmbracoContext.Current.Server.ContentXmlPath)

    Whereas NodeFactory pulls the latest content as an XMLDocument from here: UmbracoContext.Current.GetXml(), which does a check to see if the site is in preview mode and pulls the PreviewContent if required.

    T

     

  • Tim 225 posts 690 karma points
    Jul 22, 2010 @ 13:00
    Tim
    0

    I've just posted a blog post showing how you can make LInq2Umbraco work with preview http://bit.ly/a4puDN it was pretty easy thanks to the brilliant provider model of LInq2Umbraco and the extensibility of Umbraco.

    T

  • Janusz Stabik 37 posts 59 karma points
    Oct 29, 2010 @ 12:32
    Janusz Stabik
    0

    I think we are going to go with the approach of maintaining a separate XML file for preview purposes based on the following assumptions:

    - We maintain a separate preview xml file that contains all working draft content (where it exists) and all published content where working draft content doesn't exist

    - We programatically change the XML file being used in both umbraco.library and nodeFactory when used in the context of a preview request.

    - This will then allow all page templates, XSLT's and all in built library functions to use the preview file rather than the live file when in the context of a preview request.

    - As long as we dont use LinqToUmbraco specifically we are ok (unless we use the excellent article posted by Tim Saunders above.

Please Sign in or register to post replies

Write your reply to:

Draft