Copied to clipboard

Flag this post as spam?

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


  • Mark Dyer 3 posts 23 karma points
    Dec 17, 2012 @ 12:52
    Mark Dyer
    0

    Finding the media folder ID from the folders name

    Hi 

    Trying to make a very simple method of showing a gallery uploaded with 'Desktop Media Uploader'

    The bellow code works if I pass the media folder ID via querystring.... 

    http://www.myurl.com/gallery.aspx?folderid=1443

    <xsl:variable name="url" select="umbraco.library:RequestQueryString('folderid')" />

    <xsl:for-each select="umbraco.library:GetMedia($url, true())/Image">

    ....

    But the user has to login to Umbraco to find this. I want them to be able to upload a folder and then call it from the url with just the folders name. 

    http://www.myurl.com/gallery.aspx?foldername=FolderIJustUploaded

    Any ideas??

    Thanks

    Mark

  • Mark Dyer 3 posts 23 karma points
    Dec 17, 2012 @ 12:54
    Mark Dyer
    0

    Mmm.. th second link should be http://www.myurl.com/gallery.aspx?foldername=folderx

    Not sure why the forum cut that..

  • Mark Dyer 3 posts 23 karma points
    Dec 18, 2012 @ 13:57
    Mark Dyer
    0

    Ok found a solution.... loaded the root media folder (from an ID) then looped through each folder name until I find a match. Not perfect, but works....

  • Chriztian Steinmeier 2800 posts 8790 karma points MVP 8x admin c-trib
    Dec 18, 2012 @ 14:07
    Chriztian Steinmeier
    0

    Hi Mark,

    You can XPath as soon as you'e got all the XML, e.g. (replace ROOT_ID with the id of your root media folder):

    <xsl:variable name="allTheMedia" select="umbraco.library:GetMedia(ROOT_ID, true())" />
    <xsl:variable name="lookingFor" select="umbraco.library:RequestQueryString('foldername')" />
    
    <xsl:variable name="folder" select="$allTheMedia/Folder[@nodeName = $lookingFor]" />
    
    If the requested folder can be inside another, put a doubleslash between $allTheMedia and Folder (e.g.: $allTheMedia//Folder[...]) - but it will affect performance in large libraries...

    /Chriztian 

Please Sign in or register to post replies

Write your reply to:

Draft