Copied to clipboard

Flag this post as spam?

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


  • Nicolas Contreras 2 posts 22 karma points
    Aug 04, 2011 @ 17:07
    Nicolas Contreras
    0

    Child media not showing

    Hi!

    I'm trying to get the images (selected via a media picker) of the child nodes of a page to show on the parent page but I cant seem to get it right. Im getting an error that says "System.OverflowException: Value was either too large or too small for an Int32."

     

     

    The code:

    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE xsl:Stylesheet [ <!ENTITY nbsp "&#x00A0;"> ]>
    <xsl:stylesheet 
        version="1.0" 
        xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
        xmlns:msxml="urn:schemas-microsoft-com:xslt"
        xmlns:umbraco.library="urn:umbraco.library"
        exclude-result-prefixes="msxml umbraco.library">


    <xsl:output method="xml" omit-xml-declaration="yes"/>

    <xsl:param name="currentPage"/>

    <xsl:template match="/">
      
      <xsl:for-each select="$currentPage/* [@isDoc]">
        
        <xsl:variable name="productImageID" select="productImage"/>

          <div class="productContainer">
            <img class="productImage" src="{umbraco.library:GetMedia($productImageID, 'false')/umbracoFile}" />
            <h2>
              <href="{umbraco.library:NiceUrl(@id)}">
                <xsl:value-of select="@nodeName"/>
              </a>
            </h2>
            <class="productInfo"
              <xsl:value-of select="productDescription"/><br />
              <href="{umbraco.library:NiceUrl(@id)}">
                Mer info...
              </a>
            </p>
            <class="price">
              Pris: <xsl:value-of select="productPrice"/> kr<br />
            </p>
            <href="#" class="addToBasketButton">Lägg till</a>
            <img class="hr" src="/media/179/hr.gif" alt="" />
          </div>
        </xsl:for-each>
    </xsl:template>

    </xsl:stylesheet>

  • Tom Fulton 2030 posts 4996 karma points c-trib
    Aug 04, 2011 @ 17:12
    Tom Fulton
    0

    Hi,

    Try wrapping your productContainer div with the following - otherwise it can cause this error as Umbraco attempts to test your XSLT code when you save it, and if $productImageID is empty the GetMedia call will fail with the error you described.

    <xsl:if test="$productImageID != ''">
     <div class="productContainer">
        ....
      </div>
    </xsl:if>

    Hope this helps,
    Tom

  • Nicolas Contreras 2 posts 22 karma points
    Aug 04, 2011 @ 17:23
    Nicolas Contreras
    0

    You, Sir, are awesome!

  • 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