Copied to clipboard

Flag this post as spam?

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


  • Ambert van Unen 54 posts 96 karma points
    Apr 13, 2011 @ 10:40
    Ambert van Unen
    0

    Xslt split, can't get data?

    Greetings!

    I've got a little issue with a site I'm building... I don't really understand the problem at the moment.

    (using 4.6.1)

    <xsl:param name="currentPage"/>
    <xsl:template match="/">
      <xsl:choose>  
        <xsl:when test="$currentPage/banners != ''">
             <div class="bannercontainer jcarousel-skin-banner">      
              <xsl:variable name="items" select="umbraco.library:Split($currentPage/banners,',')" /> 
                <div id="slider">
                   <xsl:for-each select="$items//value">       
                     <xsl:variable name="media" select="umbraco.library:GetXmlNodeById(.)" />           
                     <xsl:variable name="media2" select="umbraco.library:GetMedia($media/banner_afbeelding, 0)" />
                     <xsl:variable name="url" select="umbraco.library:NiceUrl($media/banner_url)"/>
                     <div class="test">
                       Bannervalue: <xsl:value-of select="./banner_subject"/>
                     </div>
                  <xsl:if test="$media2">       
                    <href="{$url}"><img src="{$media2/umbracoFile}" /></a>
                  </xsl:if>  
                  </xsl:for-each>
              </div>
              <div class="bannershadow"&nbsp;</div>
            </div>
        </xsl:when>
        <xsl:otherwise>
        </xsl:otherwise>
       </xsl:choose>
    </xsl:template>

    This is the code i'm using, the idea is as follows:

    I've made a datatype:

    Name: 'Banner'
    Rendercontrol 'ultimate picker' 
    Settings: Ntext, CheckBoxList, and a parentnodeid.

    The parentnodeid links to a folder in the 'Content' section. Under this folder we've made all kinds of banners with attributes(Tekst, subject, url, image)

    In the 'Base' pages document type, I've added this datatype.

    So now when I create a new page, I can select a few banners under the 'banner' tab witch are originating from the folder 'Banners'.

    Now here's the problem, I can get (some) values from these banners (as you see in the code, the GetMedia and the NiceUrl works) But for example I can't get the subject from this banner... It's just blank!

    So...Anyone have any idea's on what I'm doing wrong?

     

  • Rob Watkins 369 posts 701 karma points
    Apr 13, 2011 @ 10:47
    Rob Watkins
    0

    Well, the obvious thing that leaps out is that you are getting the things that work using $media/field_name, and the thing that doesn't using ./field_name?

  • Rich Green 2246 posts 4008 karma points
    Apr 13, 2011 @ 10:51
    Rich Green
    0

    At the top of your xslt put this and let us know what the output is

    <xsl:value-of select="$currentPage/banners"/>
  • Dirk De Grave 4541 posts 6021 karma points MVP 3x admin c-trib
    Apr 13, 2011 @ 10:56
    Dirk De Grave
    0

    think your ./banner_subject expression is not correct, as the '.' refers to the iterated value from the for-each, in your case that would be a nodeId, whereas you're expecting a node (probably from the media section), so shouldn't that be $media/banner_subject?

     

    Cheers,

    /Dirk

  • Ambert van Unen 54 posts 96 karma points
    Apr 13, 2011 @ 11:03
    Ambert van Unen
    0

    @Rich Green, this gives the ID numbers of the selected banners

    @Rob Watkins, Omg....I've changed it to $media/banner_subject, and it works... Me and my collegue have been working on this for...2-3 hours, and I was quite sure that we tried that...a dozen times...

    So I guess I have to say...Thanks! And damn what have we been dumb...Hah!

    Ok, as I was writing this, a other question I had has been fixed, and we have NO idea what fixed it...


    Thanks again!

     

  • Rob Watkins 369 posts 701 karma points
    Apr 13, 2011 @ 11:25
    Rob Watkins
    0

    Sometimes that just happens :o) I spent an entire day last week trying to find a bug in some Javascript that turned out to be putting one line outside a conditional bracket instead of inside it... 

  • Ambert van Unen 54 posts 96 karma points
    Apr 13, 2011 @ 11:28
    Ambert van Unen
    0

    We call it, the monday-morning effect (even if its wednesday already :) )

Please Sign in or register to post replies

Write your reply to:

Draft