Copied to clipboard

Flag this post as spam?

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


  • Sam 184 posts 209 karma points
    Sep 12, 2010 @ 22:35
    Sam
    0

    Creating external link via xlst

    Hi everyone, maybe someone can help me with this, being trying for about an hour and my knowledge of xlst is very poor, but improving the more I trial and error :)

    I am trying to create a link that when clicked on, goes to an external site (from a portfolio page, launches the website which I have worked on). The alias of this external site is defined in the document type PortfolioItem:

    NAMEOFSITE &nbsp; (<span class="external-web-link"><a href="" target="_blank">Visit website</a></span>)

    I want the final output to read:

    NAME OF SITE (Visit website)

    (then when clicked on launches new window, the URL being the same as the one I have inputted into the PortfolioItem content page (with an alias of 'ProjectWebAddress')'tAny ideas? Been trying loads of combinations (also tried putting the value-of-select within the a href tag but no joy) but think I have to face it, I don't know enough to work it out! Could trial and error for days and still not get it right :(

    So far I've got this: <xsl:value-of select="current()/data [@alias = 'ProjectWebAddress']"/> but don't really know where this fits in, in the grand scheme of things.

    Thanks in advance if soneone could give me a pointer on how to create a URL from an alias that'd be great.

  • Sascha Wolter 615 posts 1101 karma points
    Sep 13, 2010 @ 00:51
    Sascha Wolter
    0

    Hi Sam,

    are you using Umbraco 4.0.* or the new 4.5.2? I assume from the code snippet above that it is the first one, but let me know if not, because then the following will not work:

    <xsl:if test="$currentPage/data[@alias='ProjectWebAddress'] != ''">
    <a href="{umbraco.library:NiceUrl($currentPage/data[@alias='ProjectWebAddress'])}" target="_blank">Visit website</a>
    </xsl:if>

    It's always good to test if the property actually contains a value or not, the method call might actually generate an error message if it hasn't got a value. Then you can use the umbraco.library:NiceUrl(nodeId) method to generate the url for a given node id.

    Hope that helps,

    Sascha

  • Sam 184 posts 209 karma points
    Sep 13, 2010 @ 20:42
    Sam
    0

    Thanks Sascha but sorry, not working for me. I'm using Umbraco 4.0.4.2.

    Just ended up with an empty p tag. Going to use a different method now, clicking on the project goes to a new page with more detail. Thanks for the help though :)

    Sam.

Please Sign in or register to post replies

Write your reply to:

Draft