Copied to clipboard

Flag this post as spam?

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


  • JL 4 posts 24 karma points
    Mar 25, 2011 @ 21:15
    JL
    0

    can't get url of file from media picker

    I can't seem to get the url for a file chosen from a media picker. Here is the xslt. Using Umbraco 4.5.2 .

     

    <xsl:variable name="srcItemsRoot" select="umbraco.library:GetXmlNodeById($currentPage/@id)"/>  

    <xsl:if test="count($srcItemsRoot/ResourceItem) != 0">
       <div class="post">
          <h3>Resources</h3>
        
            <table class="">
              <xsl:for-each select="$srcItemsRoot/ResourceItem [@isDoc]">
                <xsl:variable name="srcItemName" select="resourceItemName"/>
                <xsl:variable name="srcDocURL" select="resourceDocument"/>
                <xsl:variable name="srcItemDesc" select="itemDescription"/>    
      
                    <tr>
                      <td>
                    <!-- the line below generates the parse error -->
                       <xsl:value-of select="umbraco.library:GetMedia($srcItemsRoot/ResourceItem/resourceDocument, 0)/umbracoFile"/> 
                        
                        <href="{$srcDocURL}"><xsl:value-of select="resourceItemName"/></a></td>
                    </tr>
                   <xsl:if test="$srcItemDesc != ''">
                    <tr>
                      <td><xsl:value-of disable-output-escaping="yes" select="itemDescription"/></td>
                    </tr>
                    </xsl:if>
                    <tr>
                       <td></td>
                     </tr>
                </xsl:for-each>
            </table>
              <br/>
        </div>
    </xsl:if>

  • Tom Fulton 2030 posts 4998 karma points c-trib
    Mar 25, 2011 @ 21:26
    Tom Fulton
    0

    Try wrapping the offending line in a test to see if ti has a value, this (should) get around the parsing error and allow you to save:

    <xsl:if test="$srcItemsRoot/ResourceItem/resourceDocument != ''">
    <xsl:value-of select="umbraco.library:GetMedia($srcItemsRoot/ResourceItem/resourceDocument, 0)/umbracoFile"/>
    </xsl:if>
  • JL 4 posts 24 karma points
    Mar 25, 2011 @ 22:37
    JL
    0

    I can save it but on the page when previewing the content it shows the line "error parsing... xslt file..." where the macro should be showing the resource Item. 

  • JL 4 posts 24 karma points
    Mar 25, 2011 @ 22:56
    JL
    0

    I have made progress. Once I selected a document with the media picker for the first resource item it displayed each item with a link to that one resource item. There's more work to be done to make sure it gets the document associated with each item. 

  • rorythecheese 110 posts 56 karma points
    Mar 26, 2011 @ 00:55
    rorythecheese
    0

    How about something like this.

    <xsl:variable name="srcItems" select="$currentPage/ResourceItem[@isDoc]"/>
    <xsl:if test="count($srcItems) != 0">
        <div class="post">
            <h3>Resources</h3>
            <table>
                <xsl:for-each select="$srcItems">
                    <tr>
                        <td>
                            <xsl:choose>
                                <xsl:when test="resourceDocument !=''">
                                    <a href="{umbraco.library:GetMedia(resourceDocument, 0)/umbracoFile}">
                                        <xsl:value-of select="resourceItemName"/>
                                    </a>
                                </xsl:when>
                                <xsl:otherwise>
                                    <xsl:value-of select="resourceItemName"/>
                                </xsl:otherwise>
                            </xsl:choose>
                        </td>
                    </tr>
                    <xsl:if test="itemDescription != ''">
                        <tr>
                            <td>
                                <xsl:value-of disable-output-escaping="yes" select="itemDescription"/>
                            </td>
                        </tr>
                    </xsl:if>
                    <tr>
                        <td>
                            <xsl:comment>clear</xsl:comment>
                        </td>
                    </tr>
                </xsl:for-each>
            </table>
            <br/>
        </div>
    </xsl:if>
  • JL 4 posts 24 karma points
    Mar 28, 2011 @ 18:59
    JL
    0

    Thank you! That worked. 

Please Sign in or register to post replies

Write your reply to:

Draft