Copied to clipboard

Flag this post as spam?

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


  • Laura Holland 82 posts 103 karma points
    Jan 31, 2011 @ 19:51
    Laura Holland
    0

    urlPicker - XSLT question

    uComponents has been a real blessing - thank you! The urlPicker is exactly what I was looking for. I'm once again failing in the XSLT department.. I don't understand how to output in XSLT correctly. I have:

    <xsl:variable name="newsLinkName" select="string($featuredItem/newsLink)"/>
            <a href="{$newsLinkName}">Read full story »</a>

    But because I'm checking the "open in new window" I'm getting a url with a prefix of "true". How do I parse the info correctly?

  • Tom Fulton 2030 posts 4998 karma points c-trib
    Jan 31, 2011 @ 20:00
    Tom Fulton
    3

    Hi Laura,

    The URL Picker stores its various properties in url-picker XML nodeset, so to access each property you'd use something like:

    <xsl:variable name="newsLinkName" select="$featuredItem/newsLink/url-picker" />
    <a href="{$newsLinkName/url}">Read the full story » </a>

    But, the datatype can store different types of URL's - media, content, string, etc - so the URL field can be different depending on the type.  Here's a snippet I used in a past project to handle all different types, and the open in new window option:

           <a href="#">
              <xsl:attribute name="href">
                <xsl:choose>
                  <xsl:when test="$urlXml/@mode = 'URL'">
                    <xsl:value-of select="$urlXml/url"/>
                  </xsl:when>
                  <xsl:when test="$urlXml/@mode= 'Content'">
                    <xsl:value-of select="umbraco.library:NiceUrl($urlXml/node-id)"/>
                  </xsl:when>
                  <xsl:when test="$urlXml/@mode = 'Media'">
                    <xsl:value-of select="umbraco.library:GetMedia($urlXml/node-id,false())/umbracoFile"/>
                  </xsl:when>
                  <xsl:when test="$urlXml/@mode = 'Upload'">
                    <xsl:value-of select="$urlXml/url"/>
                  </xsl:when>         
                  <xsl:otherwise>#</xsl:otherwise>
                </xsl:choose>
              </xsl:attribute>
              <xsl:if test="string($urlXml/new-window) = 'True'"><xsl:attribute name="target">_blank</xsl:attribute></xsl:if>
              <span>Read the full story...</span>
            </a>

    Let us know if you have any questions

  • Laura Holland 82 posts 103 karma points
    Jan 31, 2011 @ 20:56
    Laura Holland
    0

    Thanks Tom, that works great.

  • Laura Holland 82 posts 103 karma points
    Jan 31, 2011 @ 22:03
    Laura Holland
    0

    Unrelated issue - I get an error when I try to save a link using Upload mode. I disabled it for now, but I might revisit it later. Where should it be saving if you use this?

  • Tom Fulton 2030 posts 4998 karma points c-trib
    Jan 31, 2011 @ 22:06
    Tom Fulton
    0

    The upload mode stores the value in the 'url' field just like the "URL" option, and (I believe) uploads the file to /media/<propertyid>/<file> just like the regular Upload datatype. 

    There is a known issue where if you save & publish twice without reloading the page you'll get an "Object reference..." error, could that be what you are experiencing?  If so please vote up the issue.  Otherwise what error are you getting and when?

  • Laura Holland 82 posts 103 karma points
    Feb 01, 2011 @ 17:28
    Laura Holland
    0

    Yes, you are right, the error was due to this known issue. I will vote the issue up. I tested it after a fresh page load and it uploads successfully into Media, though like the generic Upload datatype the file is not accessible in the Media section of the backoffice. To prevent file redundancy, I will leave it disabled. It gets confusing, having files that are there, but can't be seen in the backoffice Media section.

Please Sign in or register to post replies

Write your reply to:

Draft