Copied to clipboard

Flag this post as spam?

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


  • Hundebol 167 posts 314 karma points
    Aug 20, 2009 @ 10:43
    Hundebol
    0

    Mailto in Xslt and what do to if empty?

    Hi guys,

    I have a DocumentType with a textstring. In the textstring there is an e-mail address.

    My xslt shows this textstring like this:

    <xsl:value-of select="data [@alias = 'rcMail']"/>

    No problem there, but! How to get it to be a Mailto-link instead of just the plain text. I have tried with an "a-tag" with mailto around, but umbraco tells me i have an error in the xslt.

    I know it is probably simple, but can't figure it out! So how about just asking the experts, which i've just done!

    ----

    If empty?
    Another thing is, if there is not email-address in my textstring - the string should not be shown at all (It leaves whitespace even though it is empty)
    I have tried with an "if test" - without much luck. 

    Can you point me in some direction?

    Best regards,
    Brian

  • Dirk De Grave 4537 posts 6006 karma points MVP 3x admin c-trib
    Aug 20, 2009 @ 10:50
    Dirk De Grave
    100

    Hi,

     

    <xsl:if test="string(data[@alias = 'rcMail']) != ''">

      <a href="mailto:{string(data [@alias = 'rcMail'])}">name</a>

    </xsl:if>

     

    Cheers,

    /Dirk

  • Hundebol 167 posts 314 karma points
    Aug 20, 2009 @ 10:58
    Hundebol
    0

    Hi Dirk,

    Thanks alot! The mailto was as easy as i thought, but i simply could not figure it out...

    I was a bit fast with the solution though! The if test removes the textstring no matter if it is EMPTY or not!

    What to do?

    Show when not empty, remove when empty :)

    best regards,
    Brian

  • Hundebol 167 posts 314 karma points
    Aug 20, 2009 @ 11:26
    Hundebol
    0

    I tried a choose instead. This works in the way that it shows the text when it is there, but it still leaves whitespace, when empty!

     

     

    <xsl:choose>
    <xsl:when test="string(data[@alias = 'rcline4']) != ''">
    <!-- If empty, nothing will show! -->
    </xsl:when>
    <xsl:otherwise>
    <!-- It will show! -->
    <xsl:value-of select="data [@alias = 'rcLine4']"/><br/>
    </xsl:otherwise>
    </xsl:choose>

    Any suggestions?

     

     

  • Hundebol 167 posts 314 karma points
    Aug 20, 2009 @ 13:21
    Hundebol
    0

    It turned out that it really was an "xsl:if test" that worked. The following code work = it displays the textstring when there is any text in it, and removes the textstring/whitespace when it is empty:

    <xsl:if test="string(data[@alias = 'rcLine4']) != ''">
    <xsl:value-of select="data [@alias = 'rcLine4']"/>
    </xsl:if>

    rcLine4 is the alias of my textstring. This was exactly what Dirk wrote, so I was a bit quick - i must have made some sort of misspelling etc

    Best regards,
    Brian

  • 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