Copied to clipboard

Flag this post as spam?

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


  • saji 83 posts 38 karma points
    Oct 25, 2009 @ 16:31
    saji
    0

    How to get publish status in xslt?

    Hi all,

    Is it possible to know the specified node published or not in xslt?

    i'm showing some details by direclty giving the node id in xslt. so if the admin unpublish the node its giving error in the xslt.

    How can i resolve this issue? any help is appriciated.

  • Morten Bock 1867 posts 2140 karma points MVP 2x admin c-trib
    Oct 25, 2009 @ 18:45
    Morten Bock
    2

    You could just see if the node exists in the xml. Only published content is accessible.

    Something like (not tested)

    <xsl:choose>
        <xsl:when test="//descendant::node [@id = £youridvariable]">
            //Do your node stuff here
        </xsl:when>
        <xsl:otherwise>
            //Node does not exist
        </xsl:otherwise>
    </xsl:choose>
    
  • dandrayne 1138 posts 2262 karma points
    Oct 25, 2009 @ 18:46
    dandrayne
    0

    Hi there

    You could perhaps do a check on a value of the node whilst casting it to a string, then test if the string is empty.  You could also do it for-each for nodes matching the ID and the loop won't be entered if there isn't a published node matching that ID.

    <xsl:for-each select="$currentPage/ancestor-or-self::root//node[@id='1060']">
    <!-- node node, no loop -->
    <xsl:value-of select="current()/@id" />
    </xsl:for-each>

    Hope this helps,
    Dan

Please Sign in or register to post replies

Write your reply to:

Draft