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.
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:
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:
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
Hi,
<xsl:if test="string(data[@alias = 'rcMail']) != ''">
<a href="mailto:{string(data [@alias = 'rcMail'])}">name</a>
</xsl:if>
Cheers,
/Dirk
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
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!
Any suggestions?
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:
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
is working on a reply...