[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.
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..
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. :-)
[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.
Since (as far as i unterstand) you want to extract a property of the current iterated node all you need is just:
or, if you find it more readable:
Sorry, of course the tag in the second sample should be closed ("/>")
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
Oh yeah... I knew it was obvious. :-)
I spend four hours trying to find this.
Thanks a lot!
@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!
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
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. :-)
is working on a reply...