Copied to clipboard

Flag this post as spam?

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


  • Max 144 posts 166 karma points
    Jan 05, 2012 @ 09:23
    Max
    0

    display based on property value in xslt

    Hi all,

    I have a property called <xsl:value-of select="slideDescription"/>

     

    if this data is null in the node factory i wont display the read url link to

    that document <a href="{umbraco.library:NiceUrl(@id)}">
                  <xsl:value-of select="umbraco.library:GetDictionaryItem('readmore')"/></a>

    any code samples in xslt will be very useful

    thank you


     

     


  • Dirk De Grave 4537 posts 6006 karma points MVP 3x admin c-trib
    Jan 05, 2012 @ 09:29
    Dirk De Grave
    1

    Hi Max,

    you could use 

    <xsl:if test="string(slideDescription) != ''">
    <a href="{umbraco.library:NiceUrl(@id)}">...</a>
    </xsl:if>

     

    Cheers,

    /Dirk

  • Sebastian Dammark 547 posts 1287 karma points
    Jan 05, 2012 @ 09:39
    Sebastian Dammark
    1

    Hi Max

    I would use the normalize-space() function to check for any leading or trailing white-space.
    You can also use it to check for any input in an node, when doing like this. 

    <xsl:template match="/">
      <xsl:apply-templates select="$currentPage" />
    </xsl:template>
    
    <xsl:template match="CurrentDocumentType">
      <xsl:apply-templates select="slideDescription[normalize-space()]" />
    </xsl:template>
    
    <xsl:template match="slideDescription">
      <a href="{umbraco.library:NiceUrl(ancestor::*[@isDoc]/@id)}">
        <xsl:value-of select="umbraco.library:GetDictionaryItem('readmore')"/>
      </a>
    </xsl:template>

    Remember to change 'CurrentDocumentType' the nodename of current page.

  • Max 144 posts 166 karma points
    Jan 05, 2012 @ 09:57
    Max
    0

    thanks it was very useful :) cheers to you guys

     

  • 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