make the value-of an umbraco item render as href=""
This may be easy but I am pretty new to XSLT so I need some help.
This is the code in my xslt file right now:
<ul> <li class="phone"><xsl:value-of select="phoneNumber"/></li> <li class="email"><a><xsl:attribute name="href"><xsl:value-of select="emailAddress"/></xsl:attribute>Email me</a></li> <li class="fb"><a><xsl:attribute name="href"><xsl:value-of select="facebook"/></xsl:attribute>Find me on Facebook</a></li> </ul>
in the browser it renders:
<ul> <li class="phone"></li> <li class="email"><a href="">Email me</a></li> <li class="fb"><a href="">Find me on Facebook</a></li> </ul>
As you can see I don't have an href to make the links for facebook and email go anywhere. How do I get my value-of to be the href? One is going to be a link and one will be a 'mailto:'.
Also, the phoneNumber umbraco item doesn't have a link in it but I can't get it to just display the plain text that the user enters from my xslt.
<ul> <liclass="phone"><xsl:value-ofselect="$currentPage/phoneNumber"/></li> <liclass="email"><a><xsl:attributename="href"><xsl:value-ofselect="$currentPage/emailAddress"/></xsl:attribute>Email me</a></li> <liclass="fb"><a><xsl:attributename="href"><xsl:value-ofselect="$currentPage/facebook"/></xsl:attribute>Find me on Facebook</a></li> </ul>
For the target, you can add a single textfield to contain that value and add it like you do with the mail-url, or just type it in the textfield to keep it simple
You can just throw the target attribute on as usual, and using the curly-syntax - just add the "mailto:" where it's supposed to go - no voodoo magic required:
make the value-of an umbraco item render as href=""
This may be easy but I am pretty new to XSLT so I need some help.
This is the code in my xslt file right now:
in the browser it renders:
As you can see I don't have an href to make the links for facebook and email go anywhere. How do I get my value-of to be the href? One is going to be a link and one will be a 'mailto:'.
Also, the phoneNumber umbraco item doesn't have a link in it but I can't get it to just display the plain text that the user enters from my xslt.
Thanks for your help in advance :)
Hi Blake
Here's an example (u might have to remove the "./" part:
in your example, exchange headerLink with emailAddress
I'm guessing you need the $currentPage variable?
Rich
YAY! $currentPage populates my href! Thank you :)
Would you by chance happen to know how i would put the target="" and malto: before those links so that they work idealy? :)
I figured out the mailto: and adding the target as well. Thank you so much for your help!
<ul>
<li class="icon phone"><xsl:value-of select="$currentPage/phoneNumber"/></li>
<li class="icon mail"><a href="mailto:{$currentPage/emailAddress}">Email me</a></li>
<li class="icon fb"><a href="{$currentPage/facebook}" target="_blank">Find me on Facebook</a></li>
</ul>
Since you're basically just writing out the content of a single-line text field you can just type it in the field:
mailto:[email protected]
For the target, you can add a single textfield to contain that value and add it like you do with the mail-url, or just type it in the textfield to keep it simple
Or what you did above :-)
Hi blake,
You can just throw the target attribute on as usual, and using the curly-syntax - just add the "mailto:" where it's supposed to go - no voodoo magic required:
/Chriztian
Oh well - waaaay too slow for you :-)
lol Thank you to everyone who replied! I appreciate all the help! I always have more questions :)
is working on a reply...