This doesn't look entirely correct, what is actually in the "$currentPage/data [@alias = 'galleryImages']"? If there are nodes under this alias, then all is well, but I suspect there is a comma seperated string in there.. If so, you should use the split function while doing the for-each.
If you're having problems, please be a bit more specific about them so that we can offer better help!
Yes Sorry, should have given more details as follows:
I created a subfolder called GalleryImages under the media folder.
I then added my images within that folder.
I created a documenttype name gallery, which had a mediapicker property named GalleryImages (alias: galleryImages). This was set to piint at the folder named GalleryImages.
I then created an xslt file, with corresponding macro, which contained the xslt above.
This macro was inserted in the galletry page.
Hope that helps you understand what I'm trying to do.
So what I'm trying to achieve is to get all images from a subfolder named GalleryImages I created under the media folder, returned back to my gallery page.
Image Gallery XSLT
Hi Guys,
I've added the following xslt macro for an image gallery. Can anyone tell me if I'm doing this correctly:
<?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:variable name="ID" select="$currentPage/data [@alias = 'galleryImages']"/>
<xsl:template match="/">
<!-- start writing XSLT -->
<xsl:if test="$ID > 0">
<xsl:variable name="mediaItems" select="umbraco.library:GetMedia($ID, true())"/>
<xsl:for-each select="$mediaItems/node">
<img>
<xsl:attribute name="src">
<xsl:text>/umbraco/imagegen.ashx?image=</xsl:text>
<xsl:value-of select="current()/data[@alias='umbracoFile']"/>
<xsl:text>&width=300</xsl:text>
</xsl:attribute>
</img>
</xsl:for-each>
</xsl:if>
</xsl:template>
</xsl:stylesheet>
This doesn't look entirely correct, what is actually in the "$currentPage/data [@alias = 'galleryImages']"? If there are nodes under this alias, then all is well, but I suspect there is a comma seperated string in there.. If so, you should use the split function while doing the for-each.
If you're having problems, please be a bit more specific about them so that we can offer better help!
Yes Sorry, should have given more details as follows:
I created a subfolder called GalleryImages under the media folder.
I then added my images within that folder.
I created a documenttype name gallery, which had a mediapicker property named GalleryImages (alias: galleryImages). This was set to piint at the folder named GalleryImages.
I then created an xslt file, with corresponding macro, which contained the xslt above.
This macro was inserted in the galletry page.
Hope that helps you understand what I'm trying to do.
Saj
Re-above.
I created a content page of type gallery and the propery GalleryImages was set to point at the GalleryImages folder.
The variable ID in xslt above is set to have the ID of the galleryImages folder (I think, please correct me).
I'm Just re-looking at my xslt and this bit confuses me: <xsl:for-each select="$mediaItems/node">
is this looking for a node under my galleryImages folder?
also am I right in thinking that this xslt:
<xsl:variable name="mediaItems" select="umbraco.library:GetMedia($ID, true())"/>
gets the id of the GalleryImages folder under my medifolder?
I am setting the variable ID as follows:
<xsl:variable name="ID" select="$currentPage/data [@alias = 'galleryImages']"/>
So what I'm trying to achieve is to get all images from a subfolder named GalleryImages I created under the media folder, returned back to my gallery page.
I need something similair , but for the new Umbraco XSLT-Scheme.
I'm not sure what I need to change, for the above to work with the newer releases of Umbraco.
/Martin
Hi MRavensholt,
Take a look at the solutions on this page (they're essentially the same, just executed differently):
http://our.umbraco.org/forum/developers/xslt/15827-List-images-within-media-folders-within-top-media-folder
/Chriztian
is working on a reply...