You're actually off to a great start - so let's just continue from what you have already ('coz you've organised it neatly with templates... pluspoints given :-)
To get all levels just require a couple of simple changes - keep the $folder variable pointing to the "root" Folder so you're not confusing things (remove the /*), and then make sure to apply templates to descendants of that folder (if you know they're only of the File type - use that instead):
<xsl:variable name="folder" select="umbraco.library:GetMedia($folderid, 1)"/>
<xsl:apply-templates select="$folder//*[@nodeTypeAlias][not(self::Folder)]">
<!-- Or maybe only Files: ? -->
<xsl:apply-templates select="$folder//File" />
- to limit them to only the 5 newest, you'll need to sort and then test the position() - you're using @nodeName to sort - will that work? Can you be sure the naming will always sort correctly? Otherwise you should use the @createDate or @updateDate attributes. If you need to use position() within the item templates, you can keep the apply-templates structure (A), otherwise it probably reads a little better with a for-each (B) in this case... so:
list newest media items under folder
Hi,
Using Umbraco 4.7.1
I'm trying to list 5 newest mediaitems under a folder, having folders in it:
In the example i should get 6,7 and 8 fra the two folders
Trying to use the code below indicate that I only gets the first level.
And how do I limit the number of nodes?
Hi floffy,
I once did something alike using the paramater mediaCurrent in my macro. My Xslt looks like this where i checked all the subfolders for any new item.
Hope it helps
Thanks to Fuji
here is the result:
Hi Floffy,
You're actually off to a great start - so let's just continue from what you have already ('coz you've organised it neatly with templates... pluspoints given :-)
To get all levels just require a couple of simple changes - keep the $folder variable pointing to the "root" Folder so you're not confusing things (remove the /*), and then make sure to apply templates to descendants of that folder (if you know they're only of the File type - use that instead):
- to limit them to only the 5 newest, you'll need to sort and then test the position() - you're using @nodeName to sort - will that work? Can you be sure the naming will always sort correctly? Otherwise you should use the @createDate or @updateDate attributes. If you need to use position() within the item templates, you can keep the apply-templates structure (A), otherwise it probably reads a little better with a for-each (B) in this case... so:
/Chriztian
is working on a reply...