Copied to clipboard

Flag this post as spam?

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


  • Blake Clerke 104 posts 347 karma points
    Apr 14, 2012 @ 23:29
    Blake Clerke
    0

    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.

    Thanks for your help in advance :)

  • MartinB 411 posts 512 karma points
    Apr 14, 2012 @ 23:41
    MartinB
    0

    Hi Blake

    Here's an example (u might have to remove the "./" part:

    <a href="http://{./headerLink}" title="{./data [@alias='headerLink']}">
  • MartinB 411 posts 512 karma points
    Apr 14, 2012 @ 23:43
    MartinB
    0

    in your example, exchange headerLink with emailAddress

  • Rich Green 2246 posts 4006 karma points
    Apr 15, 2012 @ 00:17
    Rich Green
    1

    I'm guessing you need the $currentPage variable?

    <ul>
        <li class="phone"><xsl:value-of select="$currentPage/phoneNumber"/></li>
        <li class="email"><a><xsl:attribute name="href"><xsl:value-of select="$currentPage/emailAddress"/></xsl:attribute>Email me</a></li>
        <li class="fb"><a><xsl:attribute name="href"><xsl:value-of select="$currentPage/facebook"/></xsl:attribute>Find me on Facebook</a></li>
    </ul>

    Rich

  • Blake Clerke 104 posts 347 karma points
    Apr 15, 2012 @ 00:32
    Blake Clerke
    0

    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? :)

  • Blake Clerke 104 posts 347 karma points
    Apr 15, 2012 @ 01:36
    Blake Clerke
    0

    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"><href="mailto:{$currentPage/emailAddress}">Email me</a></li>
        <li class="icon fb"><href="{$currentPage/facebook}" target="_blank">Find me on Facebook</a></li>
    </ul>

  • MartinB 411 posts 512 karma points
    Apr 15, 2012 @ 01:38
    MartinB
    0

    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

  • MartinB 411 posts 512 karma points
    Apr 15, 2012 @ 01:39
    MartinB
    0

    Or what you did above :-)

  • Chriztian Steinmeier 2726 posts 8320 karma points MVP 4x admin c-trib
    Apr 15, 2012 @ 01:40
    Chriztian Steinmeier
    0

    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:

    <ul>
        <li class="phone">
            <xsl:value-of select="$currentPage/phoneNumber" />
        </li>
        <li class="email">
            <a href="mailto:{$currentPage/emailAddress}">Email me</a>
        </li>
        <li class="fb">
            <a href="{$currentPage/facebook}" target="_blank">Find me on Facebook</a>
        </li>
    </ul>

    /Chriztian 

  • Chriztian Steinmeier 2726 posts 8320 karma points MVP 4x admin c-trib
    Apr 15, 2012 @ 01:41
    Chriztian Steinmeier
    0

    Oh well - waaaay too slow for you :-)

  • Blake Clerke 104 posts 347 karma points
    Apr 15, 2012 @ 03:46
    Blake Clerke
    0

    lol Thank you to everyone who replied! I appreciate all the help! I always have more questions :)

  • 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