0

I'm trying to create a dynamic gallery with xslt and have searched the forums but can't seem to find any threads with the same problem. The idea is that users can select up to 6 pictures from the media tab on the individual content pages so that there can be different galleries on different pages. The file saves correctly, and I'm not receiving any errors, but when the page loads nothing is displayed.

The xslt

<xsl:if test="$currentPage/image &gt; 0">
    <xsl:variable name="gal1" select="umbraco.library:GetMedia($currentPage/galimg1, false())" />
    <xsl:variable name="gal2" select="umbraco.library:GetMedia($currentPage/galimg2, false())" />
    <xsl:variable name="gal3" select="umbraco.library:GetMedia($currentPage/galimg3, false())" />
    <xsl:variable name="gal4" select="umbraco.library:GetMedia($currentPage/galimg4, false())" />
    <xsl:variable name="gal5" select="umbraco.library:GetMedia($currentPage/galimg5, false())" />
    <xsl:variable name="gal6" select="umbraco.library:GetMedia($currentPage/galimg6, false())" />

    <xsl:if test="not($gal1/error)">
         <xsl:variable name="url" select="$gal1/umbracoFile" />
         <a rel="prettyPhoto [gallery]" href="{$url}">
         <img src="{$url}" />
         </a>
    </xsl:if>
    <xsl:if test="not($gal2/error)">
        <xsl:variable name="url" select="$gal2/umbracoFile" />
        <a rel="prettyPhoto [gallery]" href="{$url}">
        <img src="{$url}" />
        </a>
    </xsl:if>
    <xsl:if test="not($gal3/error)">
         <xsl:variable name="url" select="$gal3/umbracoFile" />
         <a rel="prettyPhoto [gallery]" href="{$url}">
         <img src="{$url}" />
         </a>
    </xsl:if>
    <xsl:if test="not($gal4/error)">
         <xsl:variable name="url" select="$gal4/umbracoFile" />
         <a rel="prettyPhoto [gallery]" href="{$url}">
         <img src="{$url}" />
         </a>
    </xsl:if>
    <xsl:if test="not($gal5/error)">
        <xsl:variable name="url" select="$gal5/umbracoFile" />
        <a rel="prettyPhoto [gallery]" href="{$url}">
        <img src="{$url}" />
        </a>
    </xsl:if>
    <xsl:if test="not($gal6/error)">
        <xsl:variable name="url" select="$gal6/umbracoFile" />
        <a rel="prettyPhoto [gallery]" href="{$url}">
        <img src="{$url}" />
        </a>
    </xsl:if>
</xsl:if>
Endot
  • 3
  • 4
  • Can you stick some debugging code into your XSLT to find out the value of some of the input? E.g. at the top, ``. Let us know the result. – LarsH Feb 04 '14 at 20:19
  • Adding `` before and after the first line results in no change. Adding `` after the first 6 variables also results in no change. It's not rendering in the view source in any configuration presently. – Endot Feb 04 '14 at 21:04
  • I think you're saying that when you "view source", you get a completely empty page? I'm afraid I don't have many ideas to offer ... Can you find a similar page that *does* work, and try changing things to make it similar to the above page, until it stops outputting anything? Also have you checked Umbraco error logs? (Not sure where you were referring to when you said you received no errors.) – LarsH Feb 05 '14 at 14:32
  • 1
    Re: view source, I mean that the rest of the page's code shows up but in the section that the macro should be rendering there is just blank space. Re: errors I mean that the xslt file saves without throwing an error and the page loads without any errors present in the developer console. I guess the next step is to try to get it working piece by piece, so I'll get started on that. – Endot Feb 05 '14 at 19:25

1 Answers1

0

Ended up going a different route for this issue. Rather than adding the images to the media tab and then selecting them individually from the content page, this allows users to just select an entire folder and creates the gallery that way.

<!-- Displays all images from a folder in the Media Library -->
<xsl:if test="number($mediaFolderId)">
    <div class="galleryContainer">
        <xsl:for-each select="umbraco.library:GetMedia($mediaFolderId, true())/Image">
            <xsl:if test="umbracoFile !=''">
                <a href="{umbracoFile}" title="{umbracoDescription}" rel="prettyPhoto [gallery]">
                    <img class="galleryWatermark" src="/images/logo_watermark.png" alt="{@nodeName}" title="{@nodeName}" style="background:url({umbracoFile}) top no-repeat; background-size:180px; width:100%; height:100%;" />
                </a>
            </xsl:if>
        </xsl:for-each>
    </div>
</xsl:if>
Endot
  • 3
  • 4