Copied to clipboard

Flag this post as spam?

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


  • Tizer 170 posts 201 karma points
    Dec 01, 2011 @ 06:45
    Tizer
    0

    xslt DataTyle True/False

    Warning - xslt dummy here :)

    I have a True/False datatype called 'onoff' and was hoping I could use it to turn items on of off on a page... but I am getting something wrong - This is my code:

    <xsl:choose>

    <xsl:when test="$currentPage/onoff = '1'">
    <div class="show">
    <!-- Content -->
    </div>
    </xsl:when>

    <xsl:otherwise>
    <!-- Empty -->
    </xsl:otherwise>

    </xsl:choose>

    But what I am getting is always the Empty comment.... the DataType is a checkbox which you tick or untick...

    Any ideas where I'm going wrong? Or any more efficient methods of acheiving the same thing - I'm always willing to learn.

  • Chriztian Steinmeier 2726 posts 8320 karma points MVP 4x admin c-trib
    Dec 01, 2011 @ 08:04
    Chriztian Steinmeier
    0

    Hi Tizer,

    That *should* work, so I'm guessing the alias is actually "onOff" ?

    (E.g., if you Labeled it "On/Off" on the property, the allias would be transmogrified into "onOff")

    To be sure, you can dump the entire currentPage XML to a textarea and examine it:

     <textarea rows="8" cols="40"><xsl:copy-of select="$currentPage" /></textarea> 

    /Chriztian

     

  • Tizer 170 posts 201 karma points
    Dec 01, 2011 @ 11:45
    Tizer
    0

    Hey Chriztian - I found this in the dump when it was checked

    <data alias="onoff">1</data>

    And this when it was unchecked

    <data alias="onoff">0</data>

    Ah - sorry - I have figured it out - it is an older install of umbraco which is using legacy code - this i what I needed to use... the new code looks much easier though :)

    <xsl:when test="$currentPage/self::node/data[@alias = 'onoff'] = '1'">

    That is a great tip regarding dumping the  currentPage XML though - I think I might be using that lots - thanks

     

     

  • Chriztian Steinmeier 2726 posts 8320 karma points MVP 4x admin c-trib
    Dec 01, 2011 @ 11:51
    Chriztian Steinmeier
    0

    Hi Tizer,

    That explains it :-)

    PS: Have a look at the XMLDump package for a steroids-powered view of the XML :-)

    /Chriztian

  • Chriztian Steinmeier 2726 posts 8320 karma points MVP 4x admin c-trib
    Dec 01, 2011 @ 11:53
    Chriztian Steinmeier
    0

    PPS: You can strip the self::node part from that XPath:

    <xsl:when test="$currentPage/data[@alias = 'onoff'] = 1">

    /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