Page 1 of 1

Hyperlink Email

Posted: Wed Oct 26, 2011 11:40 pm
by shansen
I am a definite noob when it comes to XSL and am trying to assist a co-worker in gaining functionality with her database. My code looks like this:

<td align="left">

<xsl:for-each select="fmrs:resultset/fmrs:record/fmrs:field[@name='Contacts::email']/fmrs:data">
<xsl:if test="position() != 1"><br/></xsl:if>
<xsl:value-of disable-output-escaping="yes" select="fmxslt:break_encode(.)"/>
<xsl:if test=". = ''">
<xsl:text disable-output-escaping="yes">&nbsp;</xsl:text>
</xsl:if>
</xsl:for-each>
</td>

I'm trying to make it where the email address that appears in the browser becomes hyperlinked. The email addresses are dynamic and not static. Any help would be greatly appreciated. Thanks!

Re: Hyperlink Email

Posted: Thu Oct 27, 2011 4:48 pm
by adrian
Hello,

Assign the current node(the email address) to a variable and add an anchor with the value from this variable(<a href="mailto:email" class="link">email</a>). Can be written in XSLT as:

Code: Select all

<xsl:variable name="email" select="."/>
<xsl:element name="a">
<xsl:attribute name="href">
<xsl:text>mailto:</xsl:text>
<xsl:value-of select="$email"/>
</xsl:attribute>
<xsl:value-of select="$email"/>
</xsl:element>
If the current node is not the email address, simply modify the expression in the select from the variable with the appropriate one.

Regards,
Adrian