Copied to clipboard

Flag this post as spam?

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


  • Dirk 13 posts 33 karma points
    Oct 14, 2011 @ 11:05
    Dirk
    0

    [Beginner] Selecting a Generic Property in a loop; not as easy as it looks

    Hello all, just started out in Umbraco and been diving into Xslt since yesterday.
    I've been lurking these forums for a few weeks, but I couldn't find the answer for this:

    <xsl:for-each select="$currentPage/childnode">
        
        <xsl:element name="input">
          
          <xsl:attribute name="type">radio</xsl:attribute>
          <xsl:attribute name="name">childnode</xsl:attribute>
          <xsl:attribute name="value"><xsl:value-of select="@nodeName" /></xsl:attribute>
    <!--So far so good, but now I want the (title) of the child to accompany the radiobutton.-->

          <xsl:value-of select="$currentPage/antwoord/(title)" />
    <!--This only gives the (title)property of the first child over the entire list-->

    <xsl:value-of select="@nodeName" /> 
    <!--(or @Id, etc... This gives me the correct results, but these are not the properties I want to select -->

          <xsl:value-of select="umbraco.library:GetItem(@id, 'titel')" />
    <!--This doesn't seem to work at all; just like anything else I tried from the library-->

        </xsl:element>
          <br />
         
        </xsl:for-each>

    Getting a little desperate right now...
    Seems like this should be a pretty basic thing to do, so I must be missing something obvious here.

    Thank you for reading; any help would be greatly appreciated.

  • Rodion Novoselov 694 posts 859 karma points
    Oct 14, 2011 @ 11:43
    Rodion Novoselov
    0

    Since (as far as i unterstand) you want to extract a property of the current iterated node all you need is just:

    <xsl:value-of select="title"/>

    or, if you find it more readable:

    <xsl:value-of select="./title"
  • Rodion Novoselov 694 posts 859 karma points
    Oct 14, 2011 @ 11:44
    Rodion Novoselov
    0

    Sorry, of course the tag in the second sample should be closed ("/>")

  • Dirk De Grave 4541 posts 6021 karma points MVP 3x admin c-trib
    Oct 14, 2011 @ 11:50
    Dirk De Grave
    0

    Dirk,

    seems you're mixing a few things here. to make things a bit clear, could you show us your content structure and what exactly you want to output?

    Rodion answers may be correct, but not sure if it will output exactly what you're trying to do based on your xslt snippet!

    Cheers,

    /Dirk

  • Dirk 13 posts 33 karma points
    Oct 14, 2011 @ 12:04
    Dirk
    0

    Oh yeah... I knew it was obvious. :-)
    I spend four hours trying to find this.

    Thanks a lot!

  • Dirk 13 posts 33 karma points
    Oct 14, 2011 @ 12:10
    Dirk
    0

    @Dirk

    I just learned to check the umbraco.config for this:

    <childnode "the things I got" >
            <titel>The thing I want</titel>
            <score>4</score>
    </childnode>

    Thanks again!

  • Dirk De Grave 4541 posts 6021 karma points MVP 3x admin c-trib
    Oct 14, 2011 @ 12:16
    Dirk De Grave
    0

    Ok, i wan't sure why you were using *childnode* and *antwoord*, but now makes perfect sense! Glad you got it working... it takes some time before you get the grips, but once you *got* it, it peanuts..

     

    Cheers,

    /Dirk

  • Dirk 13 posts 33 karma points
    Oct 14, 2011 @ 12:37
    Dirk
    0

    Oh I see,

    Seems like I was a bit careless when I translated my snippet.
    Sorry for that.

    XSLT sure looks imtimidating in the beginning.  In the end, I'm glad I made the effort to start learning it.
    It's fun, fast and powerful, even though I generally dislike all those xml jungles. :-)

Please Sign in or register to post replies

Write your reply to:

Draft