Copied to clipboard

Flag this post as spam?

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


  • J 244 posts 407 karma points
    Jun 13, 2018 @ 14:52
    J
    0

    Hide text according to value

    I have a large site with multiple templates which contain some text which i would like to hide on ALL pages unless i have ticked a checkbox (a bit like navigation structure where you can hide selected items from appearing on menus).

    The div in the template is

    <div class="someclass">Text that should NOT appear unless a tick box is ticked</div>
    

    Im using XSLT and wondered how i could do this? Or any other way to achieve the same?

    Thanks

  • Chriztian Steinmeier 2675 posts 7998 karma points MVP 2x admin c-trib
    Jun 13, 2018 @ 20:19
    Chriztian Steinmeier
    0

    Hi J,

    This is indeed possible — if your checkbox has the alias showSecretInfo you can do something like this:

    <xsl:if test="$currentPage[showSecretInfo = 1]">
        <div class="someclass">Text that should NOT appear unless a tick box is ticked</div>
    </xsl:if>
    

    Now, if the showSecretInfo checkbox only exists on e.g. the root node, you can do a recursive lookup, like this:

    <xsl:if test="$currentPage/ancestor-or-self::*[showSecretInfo = 1]">
        <div class="someclass">Text that should NOT appear unless a tick box is ticked</div>
    </xsl:if>
    

    Hope that helps,

    /Chriztian

Please Sign in or register to post replies

Write your reply to:

Draft