Copied to clipboard

Flag this post as spam?

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


  • Arjen Bloemsma 4 posts 24 karma points
    Nov 02, 2009 @ 16:20
    Arjen Bloemsma
    0

    Bug in Runway galleryListPhotos.xslt?

    Hi there,

    Yesterday i came across an issue with the Runway galleryListPhotos.xslt. I want a collection of items, regardless of how many items there are in the collection, to be rendered in rows of five. The runway gallery uses unordered lists for that. During a test i found that the 11th item in a collection of 12 isn't correctly rendered in an unordered list, but is rendered outside a list, like so:

    <ul>
       <li>item 1</li>
       <li>item 2</li>
       <li>item 3</li>
       <li>item 4</li>
       <li>item 5</li>
    </ul>
    <ul>
       <li>item 6</li>
       <li>item 7</li>
       <li>item 8</li>
       <li>item 9</li>
       <li>item 10</li>
    </ul>
    <li> item 11</li>
    <ul>
       <li>item 12</li>
    </ul>

    Obviously i wanted the 11th item to be rendered inside the third set of UL tags.

    Here's the XSLT that rendered this:

    <?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="/">
        <!-- for information on configuring the jquery lightbox, go to -->
        <!-- http://leandrovieira.com/projects/jquery/lightbox/ -->

        <!-- replace this with a real jquery reference when the api is ready -->
        <xsl:value-of select="umbraco.library:AddJquery()"/>
        <xsl:value-of select="umbraco.library:RegisterJavaScriptFile('jQueryLightbox', '/scripts/jquery.lightbox-0.5.min.js')"/>
        <xsl:value-of select="umbraco.library:RegisterJavaScriptFile('runwayGallery', '/scripts/runway.gallery.js')"/>
        <xsl:value-of select="umbraco.library:RegisterStyleSheetFile('jQueryLightboxCss', '/css/jQueryLightbox.css')"/>
        <xsl:value-of select="umbraco.library:RegisterStyleSheetFile('runwayGalleryCss', '/css/RunwayGallery.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 class="runwayGallery"&gt;</xsl:text></xsl:variable>
        <xsl:variable name="ulClose"><xsl:text>&lt;/ul&gt;</xsl:text></xsl:variable>

        <!-- <xsl:for-each select="$currentPage/node [string(data [@alias='umbracoNaviHide']) != '1' and data [@alias = 'numberOfItemsInStock']  &gt; 0]"> -->
        <xsl:for-each select="$currentPage/node [data [@alias = 'numberOfItemsInStock']  &gt; 0]">
        <xsl:sort select="@nodeName" order="ascending"/>
            <!-- 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 -->
            <li class="{position()}">
                <a href="/umbraco/ImageGen.aspx?image={data [@alias = 'umbracoFile']}&amp;constrain=true&amp;width=700&amp;height=500" class="lightbox" title="{@nodeName}">
                    <img src="{concat(substring-before(data [@alias='umbracoFile'],'.'), '_thumb.jpg')}"/>
                    <br/>
                    <b><xsl:value-of select="@nodeName"/></b>
                    <br/><br/>
                    <span style="display: block; text-align: left;">
                        Prijs: € <xsl:value-of select="data [@alias='price']"/>
                        Status: <xsl:value-of select="data [@alias='status']"/>
                        <!--
                            Aantal op voorraad: <xsl:value-of select="data [@alias='numberOfItemsInStock']"/>
                        -->
                    </span>
                </a>
            </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>


        <script type="text/javascript">
            $(function() {
                $('.nitroGallery a:rel:lightbox').lightBox({
                    imageLoading: '/css/jQueryLightboxImages/loading.gif',
                    imageBlank: '/css/jQueryLightboxImages/blank.gif',
                    imageBtnClose: '/css/jQueryLightboxImages/close.gif',
                    imageBtnPrev: '/css/jQueryLightboxImages/prev.gif',
                    imageBtnNext: '/css/jQueryLightboxImages/next.gif'
                });
            });
        </script>

    </xsl:template>

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

    </xsl:stylesheet>

    Can somebody please tell what is going wrong here and how i should correct it? Thanks in advance!

  • Ricky Beard 61 posts 116 karma points
    Nov 02, 2009 @ 18:26
    Ricky Beard
    0

    Shouldn't the logic to open a new row of images be the same as the logic to close the row (with the exception of adding or position() = last() to the closing logic)? When you open a new row you check position() mod $imagesPerRow = 0, but when closing you check position() mod ($imagesPerRow - 1) = 0. I would think that this would produce an open <ul> with a closing tag.

    You could try checking position() mod $imagesPerRow = 0 in both places and changing imagesPerRow to 5.

  • Arjen Bloemsma 4 posts 24 karma points
    Nov 03, 2009 @ 13:54
    Arjen Bloemsma
    0

    Hi Ricky,

     

    Thanks for your advice, but i already had tried that. It then renders 5 lists like so:


    <ul>
       <li>item 1</li>
       <li>item 2</li>
       <li>item 3</li>
       <li>item 4</li>
    </ul><ul>   <li>item 5</li></ul>
    <ul>
       <li>item 6</li>
       <li>item 7</li>
       <li>item 8</li>
       <li>item 9</li>
       <li>item 10</li>
    </ul>
    <li> item 11</li>
    <ul>
       <li>item 12</li>
    </ul>

     

  • Arjen Bloemsma 4 posts 24 karma points
    Nov 03, 2009 @ 14:10
    Arjen Bloemsma
    0

    Hmm, something went wrong and i can't edit the message, so here is the what i intended to say :)

    Hi Ricky,

    Thanks for your advice, but i already had tried that. It then renders 5 lists like so:

    <ul>
       <li>item 1</li>
       <li>item 2</li>
       <li>item 3</li>
       <li>item 4</li>
    </ul>
    <ul>
       <li>item 5</li>
    </ul>
    <ul>
       <li>item 6</li>
       <li>item 7</li>
       <li>item 8</li>
       <li>item 9</li>
    </ul>
    <ul>
       <li>item 10</li>
    </ul>
    <ul>
       <li>item 11</li>
       <li>item 12</li>
    </ul>

    So imagesPerRow has to be 6 (which sounds a little confusing, but that's the way the xslt was delivered with runway), at least with the current open en closing logic.

  • Ricky Beard 61 posts 116 karma points
    Nov 03, 2009 @ 18:20
    Ricky Beard
    0

    I replicated this bug and was able to fix it. Simplifying both xsl:if conditions fixes the problem.  The new xsl:if statements should look like this:

    <!-- open a row of images -->
    <xsl:if test="position() mod $imagesPerRow = 1">
     <xsl:value-of select="$ulOpen" disable-output-escaping="yes" />
    </xsl:if>

    and

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

    This also means that the $imagesPerRow variable can now be set the actual number of images you want.  So, change it to 5 instead of 6.

  • Arjen Bloemsma 4 posts 24 karma points
    Nov 10, 2009 @ 15:49
    Arjen Bloemsma
    0

    Thank you very much Ricky! You solved my problem!

  • Ulla Skaanning 67 posts 97 karma points
    Nov 29, 2009 @ 16:41
    Ulla Skaanning
    0

    Yes thank you Ricky :D

    This seems to be a general bug in Runway gallery but your advice solved it for me as well, So thank you so much 

    / Cheers

  • Marcus 41 posts 61 karma points
    Feb 06, 2011 @ 20:35
    Marcus
    0

    thank you , this solved it for me also

  • 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