Copied to clipboard

Flag this post as spam?

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


  • syn-rg 282 posts 425 karma points
    Nov 15, 2010 @ 04:33
    syn-rg
    0

    Image gallery list from child node upload field

    I'm trying to display images I've uploaded to child nodes on the parent node in a <ul> but the images aren't being displayed only the node title. I created an alias "projectImage" which has the upload datatype.

    What am I doing wrong?

    <?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:variable name="imagesPerRow" select="6"/>

    <!-- =============================================================== -->

    <xsl:template match="/">
    <xsl:value-of select="umbraco.library:RegisterStyleSheetFile('slider1', '/css/projects_anythingFader.css')"/>

    <!-- a little hack to work around the xslt syntax checker when opening/closing UL lists in two separate IF statements -->
    <!-- if it weren't for IE we could use a single UL and simply float the LI's and they'd auto-wrap -->
    <!-- but for IE we either need separate UL rows or else we need to hard-code the LI's height in CSS -->
    <!-- this approach with separate UL rows works in all browsers and row heights -->
    <xsl:variable name="ulOpen"><xsl:text>&lt;ul id="slider1"&gt;</xsl:text></xsl:variable>
    <xsl:variable name="ulClose"><xsl:text>&lt;/ul&gt;</xsl:text></xsl:variable>

    <xsl:for-each select="$currentPage/* [@isDoc][string(umbracoNaviHide) != '1']">
    <!-- open a row of images -->
    <xsl:if test="position() = 1 or position() mod $imagesPerRow = 0">
    <xsl:value-of select="$ulOpen" disable-output-escaping="yes" />
    </xsl:if>

    <!-- display each image in the row, with the count of photos in each gallery -->
      <li>
        <img src="/umbraco/ImageGen.ashx?image={./data[@alias = 'projectImage']}&amp;width=738&amp;height=300&amp;constrain=true" alt="{@nodeName}" title="{@nodeName}"/>
      </li>

    <!-- close the row of images -->
    <xsl:if test="position() = ($imagesPerRow - 1) or position() mod ($imagesPerRow - 1) = 0 or position() = last()">
    <xsl:value-of select="$ulClose" disable-output-escaping="yes"/>
    </xsl:if>
    </xsl:for-each>

    </xsl:template>

    <!-- =============================================================== -->

    </xsl:stylesheet>
  • syn-rg 282 posts 425 karma points
    Nov 15, 2010 @ 07:32
    syn-rg
    0

    Don't worry I've solved this, here's my code just incase:

    <?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:variable name="imagesPerRow" select="6"/>

    <!-- =============================================================== -->

    <xsl:template match="/">
    <xsl:value-of select="umbraco.library:RegisterStyleSheetFile('slider1', '/css/projects_anythingFader.css')"/>

    <!-- a little hack to work around the xslt syntax checker when opening/closing UL lists in two separate IF statements -->
    <!-- if it weren't for IE we could use a single UL and simply float the LI's and they'd auto-wrap -->
    <!-- but for IE we either need separate UL rows or else we need to hard-code the LI's height in CSS -->
    <!-- this approach with separate UL rows works in all browsers and row heights -->
    <xsl:variable name="ulOpen"><xsl:text>&lt;ul id="slider1"&gt;</xsl:text></xsl:variable>
    <xsl:variable name="ulClose"><xsl:text>&lt;/ul&gt;</xsl:text></xsl:variable>

    <xsl:for-each select="$currentPage/* [@isDoc][string(umbracoNaviHide) != '1']">
    <!-- open a row of images -->
    <xsl:if test="position() = 1 or position() mod $imagesPerRow = 0">
    <xsl:value-of select="$ulOpen" disable-output-escaping="yes" />
    </xsl:if>

    <!-- display each image in the row, with the count of photos in each gallery -->
      <li>
        <xsl:if test="projectImage != ''">
          <img alt="">
          <xsl:attribute name="src">
            <xsl:value-of select="projectImage" />
          </xsl:attribute>  
        </img>
        </xsl:if>
      </li>

    <!-- close the row of images -->
    <xsl:if test="position() = ($imagesPerRow - 1) or position() mod ($imagesPerRow - 1) = 0 or position() = last()">
    <xsl:value-of select="$ulClose" disable-output-escaping="yes"/>
    </xsl:if>
    </xsl:for-each>

    </xsl:template>

    <!-- =============================================================== -->

    </xsl:stylesheet>
  • 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