Copied to clipboard

Flag this post as spam?

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


  • Probocop 51 posts 71 karma points
    Dec 03, 2010 @ 17:25
    Probocop
    0

    Check if current page is a descendant of a certain page?

    Hi,

    On the site I'm currently developing there is a specific section on the site that requires an additional stylesheet loading.

    I'm trying to write an <xsl:if> statement which basically says - If current page, ancestor or self has the ID of '1065'

    I can't quite get it right though, how could I achieve this?

    Thanks!'

  • Jason Prothero 422 posts 1243 karma points MVP c-trib
    Dec 03, 2010 @ 17:44
    Jason Prothero
    1

    In 4.0 it would be something like this I believe:

    <xsl:if test="count($currentPage/ancestor-or-self::node[@id = 1065]) &gt; 0">
    ...
    </xsl:if>

    4.5 something like this

    <xsl:if test="count($currentPage/ancestor-or-self::*[@isDoc and @id = 1065]) &gt; 0">
    ...
    </xsl:if>

    Haven't actually tested these but they're close if not quite right.

  • Probocop 51 posts 71 karma points
    Dec 03, 2010 @ 17:54
    Probocop
    0

    That is spot on, thank you very much!

  • Jason Prothero 422 posts 1243 karma points MVP c-trib
    Dec 03, 2010 @ 17:59
    Jason Prothero
    0

    Glad to help!

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies