Copied to clipboard

Flag this post as spam?

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


  • Sajid Riaz 142 posts 165 karma points
    Jun 22, 2010 @ 22:28
    Sajid Riaz
    0

    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 "&#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" 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 &gt; 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>&amp;width=300</xsl:text>
        </xsl:attribute>
    </img>
    </xsl:for-each>
    </xsl:if>

    </xsl:template>

    </xsl:stylesheet>

  • Sebastiaan Janssen 5060 posts 15522 karma points MVP admin hq
    Jun 23, 2010 @ 02:24
    Sebastiaan Janssen
    0

    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!

  • Sajid Riaz 142 posts 165 karma points
    Jun 23, 2010 @ 11:00
    Sajid Riaz
    0

    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

  • Sajid Riaz 142 posts 165 karma points
    Jun 23, 2010 @ 11:09
    Sajid Riaz
    0

    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.

     

  • MRavensholt 19 posts 39 karma points
    Feb 01, 2011 @ 13:56
    MRavensholt
    0

    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

  • Chriztian Steinmeier 2800 posts 8791 karma points MVP 8x admin c-trib
    Feb 01, 2011 @ 14:05
    Chriztian Steinmeier
    0

    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

Please Sign in or register to post replies

Write your reply to:

Draft