I have created a xslt/macro with a mediaCurrent paramter. What I want to achieve is to iterate (and display) the child nodes (ie images) in the selected media node (ie my mediaCurrent, wich should be a folder).
Any thought on how to do this?
This is what i got, wich only seems to display the actual mediaCurrent, but none of its child nodes.
I guess the medianode parameter had a media picker assigned so it is the id of the folder. Then you can get all the medias in the folder with umbraco.library:Getmedia(). See the wiki here for the documentation (or search the forum for Getmedia, there are tons of entries). If you need help just repost.
What you are getting is only the node in your content, when you want to get the media node (in order to get the children of the media node) which is what getmedia returns:
the if test is needed for saving the xslt, cause the xslt is tested against the first node (which propably has not the mediaFolder property). the getmedia with deep set to true will return the node structure of the selected media node inclusing all children (and grandchildren). so you can iterate through the subnodes via $medianode2/node
Macro and mediaCurrent
Hi all,
I have created a xslt/macro with a mediaCurrent paramter. What I want to achieve is to iterate (and display) the child nodes (ie images) in the selected media node (ie my mediaCurrent, wich should be a folder).
Any thought on how to do this?
This is what i got, wich only seems to display the actual mediaCurrent, but none of its child nodes.
<xsl:variable name="medianode" select="/macro/mediaNode"/> <xsl:template match="/"> <xsl:for-each select="$medianode/node"> <xsl:value-of select="@nodeName"/> </xsl:for-each> </xsl:template>
/D
I guess the medianode parameter had a media picker assigned so it is the id of the folder. Then you can get all the medias in the folder with umbraco.library:Getmedia(). See the wiki here for the documentation (or search the forum for Getmedia, there are tons of entries). If you need help just repost.
Cheers, Thomas
Thanks Thoms.
Yes, I do have a MediaPicker in the document type. Hm, this get me thinking that I dont need the macro paramter at all?
I can just get my media folder node by using $currentPage/data[@alias='mediaFolder'] ?
This lead me to try this:
<xsl:param name="currentPage"/> <xsl:variable name="medianode2" select="$currentPage/data[@alias='mediaFolder'] "/> <xsl:template match="/"> <xsl:for-each select="medianode2/node"> <xsl:value-of select="@nodeName"/> </xsl:for-each> </xsl:template>
Wich also does not work. Where do I need to put the GetMedia()? I really do not need to get the actual media node, but rather it's child nodes...
Try this:
The xml structure returned from GetMedia is similiar to the xml structure of the content nodes.
hth, Thomas
What you are getting is only the node in your content, when you want to get the media node (in order to get the children of the media node) which is what getmedia returns:
Ah, forgot the $:
Adding some explanation:
the if test is needed for saving the xslt, cause the xslt is tested against the first node (which propably has not the mediaFolder property). the getmedia with deep set to true will return the node structure of the selected media node inclusing all children (and grandchildren). so you can iterate through the subnodes via $medianode2/node
hth, Thomas
Works great Thomas! I'll be sure to look deeper into the GetMedia() logic.
/D
is working on a reply...