To make the output a bit more readable you wrap the xsl:copy-of statement in Chris' sample in a <textarea></textarea>...then you can copy/paste the output to a file where it's easy to see the returned XML.
So I am getting the media folder passed through. My understanding is that I need the 'media folder ID' so that I can process the images in the folder by;
Node won't match anything since you are using the new xml schema - Node is from the legacy schema so I think that is what's confusing you :-)
Try to make a copy-of on the $images variable to see the output you get returned (can't remember the syntax as I write). You probably get one or more <image> elements returned. But have a look to be sure.
The reason you need that test is because Umbraco will execute the transform upon "Save" to make sure it's a valid file. It won't, however, put anything in the macro parameters, thus making the call to GetMedia() fail.
Here's another way to do it that's a little bit more 'XSLT'-ish, if you like:
<xsl:param name="currentPage" />
<xsl:template match="/">
<!-- Only process sliderImages if it holds an id -->
<xsl:apply-templates select="$currentPage/sliderImages[normalize-space()]" />
</xsl:template>
<xsl:template match="sliderImages">
<!-- Get contents of folder -->
<xsl:variable name="images" select="umbraco.library:GetMedia(., true())" />
<!-- Process all images with a specified file -->
<xsl:apply-templates select="$images/descendant-or-self::Image[umbracoFile]" />
</xsl:template>
<xsl:template match="Image">
<li>
<img src="{umbracoFile}" alt="[image]" height="{umbracoHeight}" width="{umbracoWidth}" />
</li>
</xsl:template>
Parameter of mediaCurrent doesn't have value
I want to pass a media folder as a parameter to an XSLT function and use it to produce an HTML list of images in that folder.
As an XSLT newbie I've researched the examples and have;
- A macro parameter of: Alias = MediaNode & Type = mediaCurrent
- Added the macro to my template via the UI, set the media folder and it shows as;
The XSLT code for Sample within starts with;
I never get a value for the media folder passed through to the XSLT but I can pass text parameters with no problem.
Any help appreciated.
Try
Chris
To make the output a bit more readable you wrap the xsl:copy-of statement in Chris' sample in a <textarea></textarea>...then you can copy/paste the output to a file where it's easy to see the returned XML.
Just at little tip.
/Jan
Have wrapped the xsl:copy of statement in a textarea - good tip !
It returns;
mediaFolder: <MediaNode><Folder id="1183" version="366c8233-4c43-410b-ad10-bbaf349f32e1" parentID="-1" level="1" writerID="0" nodeType="1031" template="0" sortOrder="49" createDate="2010-10-30T08:28:43" updateDate="2010-10-30T08:28:43" nodeName="Slider Images" urlName="sliderimages" writerName="Administrator" nodeTypeAlias="Folder" path="-1,1183"><contents /></Folder></MediaNode>
So I am getting the media folder passed through.
My understanding is that I need the 'media folder ID' so that I can process the images in the folder by;
I'm referring to the example at http://our.umbraco.org/wiki/reference/code-snippets/listfilesfrommediafolderxslt for guidance but the statement
doesn't ring true (or work) for me.
Would appreciate another clue, excuse me if I don't reply promptly it's getting late here.
Chris C.
Node won't match anything since you are using the new xml schema - Node is from the legacy schema so I think that is what's confusing you :-)
Try to make a copy-of on the $images variable to see the output you get returned (can't remember the syntax as I write). You probably get one or more <image> elements returned. But have a look to be sure.
/Jan
Hi,
Thanks for the hints, I eventually got there and learnt a lot in the process.
My code is now;
I was surprised to realise that this clause is necessary for the XSLT to compile;
Perhaps I'm looking at it from a .Net not an XSL point of view but I always thought IF statements were only evaluated at runtime ?
Again - thanks
Chris C.
Hi Chris,
The reason you need that test is because Umbraco will execute the transform upon "Save" to make sure it's a valid file. It won't, however, put anything in the macro parameters, thus making the call to GetMedia() fail.
Here's another way to do it that's a little bit more 'XSLT'-ish, if you like:
/Chriztian
Thank-you, I understand better now what it's trying to do.
I've implemented your code and it works fine.
I kind of understand the code but realise that my XSLT skills need more work.
Thanks.
is working on a reply...