Copied to clipboard

Flag this post as spam?

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


  • Scott 69 posts 146 karma points
    Mar 08, 2012 @ 18:51
    Scott
    0

    Detect Preview Mode from xslt

    I know from within XSLT you can use the umbraco libraries to get at session variables and other things. Is there a way to determine if you are in preview mode? 

    Running 4.7.1

  • Lee Kelleher 4020 posts 15802 karma points MVP 13x admin c-trib
    Mar 08, 2012 @ 18:57
    Lee Kelleher
    1

    Hi Scooter,

    When you are in Preview mode, a cookie with the name of "UMB_PREVIEW" is set.  So you could check for that in your XSLT?

    <xsl:if test="umbraco.library:RequestCookies('UMB_PREVIEW') != ''">
        ...
    </xsl:if>

    (I haven't tested this)

    Cheers, Lee.

  • Scott 69 posts 146 karma points
    Mar 08, 2012 @ 19:07
    Scott
    0

    Works like a charm! Thanks!

  • Fabio Milheiro 74 posts 136 karma points
    Aug 16, 2014 @ 01:45
    Fabio Milheiro
    0

    Why is "works like a charm" the accepted answer? pfff..

  • Chriztian Steinmeier 2798 posts 8787 karma points MVP 7x admin c-trib
    Aug 16, 2014 @ 13:40
    Chriztian Steinmeier
    0

    Hi Fabio,

    I guess it's just a mistake; I think I've seen it happen before. And once you've marked an answer as the "accepted" one, you can't change it back.

    (And you don't get karma for answering your own questions, so there's no gain in doing it on purpose either :)

    /Chriztian

Please Sign in or register to post replies

Write your reply to:

Draft