Copied to clipboard

Flag this post as spam?

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


  • J 351 posts 606 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 2726 posts 8320 karma points MVP 4x 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

  • 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