Apologies for this post. i can see a lot of similar questions but none of the posts are helping me.
I have a mediafolder with a couple of pdf files and an image, just for testing. All i want is a list of all the files in the mediafolder(or just the pdf's), but i can only get out images. Tried with node, umbracoFile, data, ect ect. nothing comes up. However, if i change /node to /Image it shows a link to the image.
What version of Umbraco are you using? Since Umbraco 4.5 the XML schema changes and in the above you're looping through each "node" element in the XML. But if you're using a newer version of Umbraco that element does not exist anymore (unless it's an upgraded version where the useLegacyXML has been set to true in the umbracoSettings.config file). The data element and [@alias] stuff is also a leftover from back then. Since you get something when using "/Image" I'm pretty confident you're matching against the new schema.
It's also a good idea to see what XML the variable is returning, which you can do by writing a textarea like this:
Also be aware that when using GetMedia extension setting the second parameter to 'true' is the same as writing anything in plings so 'unicorn' will also return true. The same will 'false'. To make sure you give the extension the proper information the second parameter needs to be either 0,1,true() or false() like this
umbraco.library:GetMedia($mediaFolderId,true()) (no plings!).
When we're certain what schema you're using we can have a look at a nicer example of how to list the files and medias within the folder.
List Files from MediaFolder
Apologies for this post. i can see a lot of similar questions but none of the posts are helping me.
I have a mediafolder with a couple of pdf files and an image, just for testing.
All i want is a list of all the files in the mediafolder(or just the pdf's), but i can only get out images.
Tried with node, umbracoFile, data, ect ect. nothing comes up.
However, if i change /node to /Image it shows a link to the image.
Researching keeps leading me to a gamut of sites saying that getmedia is broken, or that getmedia works just like i have tried unsuccesfully.
Hi Andreas
What version of Umbraco are you using? Since Umbraco 4.5 the XML schema changes and in the above you're looping through each "node" element in the XML. But if you're using a newer version of Umbraco that element does not exist anymore (unless it's an upgraded version where the useLegacyXML has been set to true in the umbracoSettings.config file). The data element and [@alias] stuff is also a leftover from back then. Since you get something when using "/Image" I'm pretty confident you're matching against the new schema.
It's also a good idea to see what XML the variable is returning, which you can do by writing a textarea like this:
<textarea>
<xsl:copy-of select="$mediaFolder" />
</textarea>
Also be aware that when using GetMedia extension setting the second parameter to 'true' is the same as writing anything in plings so 'unicorn' will also return true. The same will 'false'. To make sure you give the extension the proper information the second parameter needs to be either 0,1,true() or false() like this
umbraco.library:GetMedia($mediaFolderId,true()) (no plings!).
When we're certain what schema you're using we can have a look at a nicer example of how to list the files and medias within the folder.
Looking forward to hearing from you.
/Jan
Hi Jan, sorry about the lack of details.
I am running version 4.7.0
Here is my revised code, set to /Image wich returns the one image in the folder.
hm, looks like i've been missing the forrest for the trees.
Simply selecting using the * all selector gives me every file in the folder.
Looking at my output, it seems like i also get the folder node itself, since there is a node with only the ../@nodeName value.
Now i just have to make links to the files.
aaand linking fails spectacularly.
Following code gives me a link to "#" (although each @id is a propper value eg 1976)
Hi Andreas,
That's because the NiceUrl() extension only works on Content - the URL for the image is actually available in the umbracoFile property, e.g.:
/Chriztian
Thanks Chriztian :)
is working on a reply...