I want to create a simple gallery. The user uploads photo's to a folder in the media section. He then creates a page and selects the nodeID with the mediapicker (ccGalleryFolder). This is the XSLT, but it doesn't work. Can someone explain me the mistake(s) I've made?
The call to GetMedia() should just use the $imageFolder value directly (it's the ID of the folder). Also, you should use true() or 1 as the second parameter:
Listing images from a user-selected mediafolder
I want to create a simple gallery. The user uploads photo's to a folder in the media section. He then creates a page and selects the nodeID with the mediapicker (ccGalleryFolder). This is the XSLT, but it doesn't work. Can someone explain me the mistake(s) I've made?
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE xsl:stylesheet [ <!ENTITY nbsp " "> ]> <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" xmlns:Exslt.ExsltCommon="urn:Exslt.ExsltCommon" xmlns:Exslt.ExsltDatesAndTimes="urn:Exslt.ExsltDatesAndTimes" xmlns:Exslt.ExsltMath="urn:Exslt.ExsltMath" xmlns:Exslt.ExsltRegularExpressions="urn:Exslt.ExsltRegularExpressions" xmlns:Exslt.ExsltStrings="urn:Exslt.ExsltStrings" xmlns:Exslt.ExsltSets="urn:Exslt.ExsltSets" exclude-result-prefixes="msxml umbraco.library Exslt.ExsltCommon Exslt.ExsltDatesAndTimes Exslt.ExsltMath Exslt.ExsltRegularExpressions Exslt.ExsltStrings Exslt.ExsltSets "> <xsl:output method="xml" omit-xml-declaration="yes"/> <xsl:param name="currentPage"/> <xsl:template match="/"> <xsl:variable name="imageFolder" select="./data[@alias = 'ccGalleryFolder']" /> <xsl:variable name="imageFolderContents" select="umbraco.library:GetMedia($imageFolder/node/@id, 'true')"/> <xsl:for-each select="$imageFolderContents/node [@nodeTypeAlias='Image']"> <div class="referenties"> <xsl:if test="string(current()/data [@alias='umbracoFile']) != ''"> <img alt="{current()/@nodeName}"> <xsl:attribute name="src"> <xsl:text>/umbraco/ImageGen.ashx?image=</xsl:text> <xsl:value-of select="./data [@alias = 'umbracoFile']" /> </xsl:attribute> </img> </xsl:if> </div> </xsl:for-each> </xsl:template> </xsl:stylesheet>Thanks!
Ralph
Hi Raph,
The call to GetMedia() should just use the $imageFolder value directly (it's the ID of the folder). Also, you should use true() or 1 as the second parameter:
/Chriztian
Hi Chriztian,
Thanks for the help. It still doesn't work, but I think there is a problem with the rest of the xslt, so I will try to fix that first.
Ralph
Took me a while, but figured it out. The problem was I didn't know how to pass a nodeID to a macro which is, in fact, pretty easy.
<umbraco:Macro imageFolder="[#ccGalleryFolder]" Alias="Gallery" runat="server"></umbraco:Macro>
ccGallery is the alias of a mediaPicker in the DocType which selects the imagefolder in the Mediasection.
Works like a charm.
is working on a reply...
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.