Copied to clipboard

Flag this post as spam?

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


  • Claushingebjerg 939 posts 2574 karma points
    Nov 12, 2010 @ 15:39
    Claushingebjerg
    0

    showing media from mulit-node picker recursively

    Im using the multi-node picker to select images for a "slideshow" at the top of my pages.

    I would like to make it so that if a page has NO images selected, the parent's images are shown. If the parent have NO images selected, the parent above... and so on.

    How do i do this with the multi node picker???

      <xsl:for-each select="$currentPage/ancestor-or-self::* /topbilleder/MultiNodePicker/nodeId">

    returns some images, but not just the parents images...?!?!

  • Rich Green 2246 posts 4008 karma points
    Nov 12, 2010 @ 15:44
    Rich Green
    0

    Hey,

    As long as your MultiNodePicker property is the same name for all the nodes you can do this

    <xsl:variable name="mntp_images" select="$currentPage/ancestor-or-self::* [@isDoc][string(MultiNodePicker)!=''] [position()=1]" />

    This will look at the current node then up the tree to get the first value that is not empty (thanks to Doug Robar for this tip)

    Rich

  • Claushingebjerg 939 posts 2574 karma points
    Nov 12, 2010 @ 15:48
    Claushingebjerg
    0

    Thanks, but could you post the entire <xsl:for-each.... Like:

    <xsl:variable name="mntp_images" select="$currentPage/ancestor-or-self::* [@isDoc][string(MultiNodePicker)!=''] [position()=1]" />
    <xsl:for-each select=" (whatever goes here) ">
      <xsl:variable name="node" select="umbraco.library:GetMedia(.,'true')" />
              <img>
                <xsl:attribute name="src">
                <xsl:value-of select="$node/umbracoFile" />
                </xsl:attribute>
              </img>
          </xsl:for-each>

    That would help me a lot ;)

  • Rich Green 2246 posts 4008 karma points
    Nov 12, 2010 @ 16:03
    Rich Green
    0

    My code above would only work for when uComponents is set to hold csv values

    Not tested but should work

    <xsl:variable name="mntp_images" select="$currentPage/ancestor-or-self::* [@isDoc][string(MultiNodePicker)!=''] [position()=1]" />
    <xsl:variable name="splitImages" select="umbraco.library:Split($mntp_images, ',')" />
    
    <xsl:for-each select="$splitResults/value">
    
          <xsl:variable name="mediaId" select="." />
    
        <xsl:if test="$mediaId > 0">
    
            <xsl:variable name="mediaNode" select="umbraco.library:GetMedia($mediaId, 0)" />
    
            <xsl:if test="$mediaNode/umbracoFile">
    
                <img src="{$mediaNode/umbracoFile}" alt="[image]" height="{umbracoHeight}" width="{umbracoWidth}" />
    
            </xsl:if>
    
        </xsl:if>
    
    
    
    </xsl:for-each>

    Rich

  • Rich Green 2246 posts 4008 karma points
    Nov 12, 2010 @ 16:28
    Rich Green
    0

    Sorry, typo above ($splitImages not $splitResults) and can't edit it

    <xsl:variable name="mntp_images" select="$currentPage/ancestor-or-self::* [@isDoc][string(MultiNodePicker)!=''] [position()=1]" />
    <xsl:variable name="splitImages" select="umbraco.library:Split($mntp_images, ',')" />
    
    <xsl:for-each select="$splitImages/value">
    
          <xsl:variable name="mediaId" select="." />
    
        <xsl:if test="$mediaId > 0">
    
            <xsl:variable name="mediaNode" select="umbraco.library:GetMedia($mediaId, 0)" />
    
            <xsl:if test="$mediaNode/umbracoFile">
    
                <img src="{$mediaNode/umbracoFile}" alt="[image]" height="{umbracoHeight}" width="{umbracoWidth}" />
    
            </xsl:if>
    
        </xsl:if>
    
    </xsl:for-each>
  • Claushingebjerg 939 posts 2574 karma points
    Nov 12, 2010 @ 16:35
    Claushingebjerg
    0

    Yeah i spotted that one, but i cant get it to work anyway... Is MultiNodePicker here:

    [string(MultiNodePicker)!=''] 

    the alias on my document type? In my case called "topbilleder" . Or is it a global naming for that specifik Datatype?

     

    -  My MultiNodePicker returns XML, isnt the splitfunction unnecessary then?

  • Rich Green 2246 posts 4008 karma points
    Nov 12, 2010 @ 16:40
    Rich Green
    0

    That is the name of your MNTP property, so for your code

    <xsl:variable name="mntp_images" select="$currentPage/ancestor-or-self::* [@isDoc][string(topbilleder)!=''] [position()=1]" />

    Sorry, don't know how to make this work for having MNTP set to XML and the above code won't work, so you can either change your MNTP to csv (remember to publish your nodes after the change) or adapt the above code to work with XML using the code at the bottom of this page http://ucomponents.codeplex.com/wikipage?title=MultiNodeTreePicker&referringTitle=Documentation

    Rich

  • adrianfriend 67 posts 68 karma points
    Nov 12, 2010 @ 20:16
    adrianfriend
    1

    Think something like the below would work if it was XML.

    <xsl:for-each select="$currentPage/ancestor-or-self::* [@isDoc][string(topbilleder)!=''] [position()=1] /topbilleder/MultiNodePicker/nodeId">

     

Please Sign in or register to post replies

Write your reply to:

Draft