Copied to clipboard

Flag this post as spam?

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


  • Matt Bertulli 7 posts 27 karma points
    Jan 26, 2010 @ 17:09
    Matt Bertulli
    0

    Tree Multi Picker - Can't list out media nodes

    I used the code provided by the best practice for listing download files post, but I'm not getting any output when I try and list out my download files.

    My XSLT looks like this:

    <xsl:template match="/">        
            <xsl:if test="string($currentPage/data [@alias='Files']) != ''">
                <ul class="nav">
                    <xsl:variable name="documentNodeSet" select="$currentPage/data [@alias='Files']"/>

                    <xsl:value-of select="$documentNodeSet/descendant::node"/>
                   
                    <xsl:for-each select="$documentNodeSet/descendant::node">
                        <li>
                            <a href="{umbraco.library:GetMedia(current(), 'false')/data [@alias='umbracoFile']}">
                                <xsl:value-of select="umbraco.library:GetMedia(current(), 'false')/@nodeName" />
                            </a>
                        </li>
                    </xsl:for-each>
                </ul>
            </xsl:if>
        </xsl:template>

    If I do a value-of and select the

    string($currentPage/data [@alias='Files'])

    all I get are the ids of the two uploaded files (example output - 123,124)

    Anybody have any ideas why this isn't working?

  • Chriztian Steinmeier 2726 posts 8320 karma points MVP 4x admin c-trib
    Jan 26, 2010 @ 17:36
    Chriztian Steinmeier
    0

    Hi Matt,

    Two things:

    1. By using "current()" you're sending the actual node into the GetMedia() method - you need to send the id, which should be on a data element under that node.
    2. You need to use false() or 0 (zero) instead of 'false' to not have have GetMedia() return childnodes as well   

    Oh, and one more thing: Make sure you at least cache the call to GetMedia in a variable, so you're not calling it more than necessary

    /Chriztian

    PS: Also, try searching the Wiki for GetMedia() 

  • Matt Bertulli 7 posts 27 karma points
    Jan 26, 2010 @ 18:05
    Matt Bertulli
    0

    Thanks for the response Chriztian.  The problem I'm having is that my for-each produces no data at all. No nodes, nothing.  Any ideas why

     <xsl:variable name="documentNodeSet" select="$currentPage/data [@alias='Files']"/>

    won't give me nodes to iterate through?

  • Matt Bertulli 7 posts 27 karma points
    Jan 26, 2010 @ 18:08
    Matt Bertulli
    0

    I think I might see one issue.  The field "Files" only holds the comma seperated list of media file ids.  How can this be considered a node?  Might be a newbie question, just trying to figure out how I can work with this Tree Multi Picker data type.

  • Sebastiaan Janssen 4899 posts 14655 karma points MVP admin hq
    Jan 26, 2010 @ 18:38
    Sebastiaan Janssen
    0

    Are you sure they are comma seperated? Did you do value-off If you do copy-of, it will output the real underlying XML.

    If it is a comma seperated string, you can easily split them like so:

    <xsl:variable name="files" select="umbraco.library:Split($params, ',')" />

    Again, use something like:

    <xsl:copy-of select="$files" /> 

    That would give you the xml fragment that you can work with.

  • Matt Bertulli 7 posts 27 karma points
    Jan 26, 2010 @ 18:42
    Matt Bertulli
    0

    doing a copy-of gives me: 1160,1161

     

  • Sebastiaan Janssen 4899 posts 14655 karma points MVP admin hq
    Jan 26, 2010 @ 18:45
    Sebastiaan Janssen
    0

    Great, so all you have to do now is the split and start using the values from there :-)

  • Sebastiaan Janssen 4899 posts 14655 karma points MVP admin hq
    Jan 26, 2010 @ 18:46
    Sebastiaan Janssen
    0

    Oh you should use

    $currentPage/data [@alias='Files']

    Where my code says $params

  • Matt Bertulli 7 posts 27 karma points
    Jan 26, 2010 @ 18:52
    Matt Bertulli
    0

    OK!  Thanks Sebastian.  Here is what the working solution looks like for listing files out with the Tree Multi Picker package.

    <xsl:if test="string($currentPage/data [@alias='Files']) != ''">
                <h4>Download Files</h4>
                <ul class="fileList">
                    <xsl:variable name="documentNodeSet" select="umbraco.library:Split(string($currentPage/data [@alias='Files']), ',')"/>               

                    <xsl:for-each select="$documentNodeSet//value">
                        <li>
                            <a href="{umbraco.library:GetMedia(current(), false())/data}">
                                <xsl:value-of select="umbraco.library:GetMedia(current(), 'false')/@nodeName" />
                            </a>
                        </li>
                    </xsl:for-each>
                </ul>
            </xsl:if>
  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies