Copied to clipboard

Flag this post as spam?

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


  • Topic author was deleted

    Feb 22, 2011 @ 20:29

    for each loop tags library

    Hi,

    I am having trouble with looping through all items which have the same tags.

    <xsl:for-each select="tags:getEverythingWithTags('test')">
         <xsl:value-of select="current()/@nodeName"/>
     </xsl:for-each>

    <xsl:copy-of select="tags:getEverythingWithTags('test')"/> gives me following output
    <root><node id="1076" parentID="1057" level="2" writerID="0" sortOrder="7" createDate="2011-01-04T22:18:20" nodeName="Ap" path="-1,1057,1076" /><node id="1077" parentID="1057" level="2" writerID="0" sortOrder="0" createDate="2011-01-04T22:18:40" nodeName="Mt" path="-1,1057,1077" /></root>

    What am i doing wrong?
    Thnx

  • Jan Skovgaard 11280 posts 23678 karma points MVP 11x admin c-trib
    Feb 22, 2011 @ 20:57
    Jan Skovgaard
    0

    Hi Bart

    try changing the value-of to this

    <xsl:value-of select="current()/root/node/@nodeName" /> or <xsl:value-of select="current()/node/@nodeName" /> perhaps.

    Does this help?

    /Jan

  • Comment author was deleted

    Feb 22, 2011 @ 21:40

    Hi Jan,

    I get an output wehn i use:

     <xsl:for-each select="tags:getEverythingWithTags('test')">
           <xsl:value-of select="current()/root/node/@nodeName" />
     </xsl:for-each>

    but only the first node of  the 2 nodes is shown.

    <root>
    <node id="1076" parentID="1057" level="2" writerID="0" sortOrder="7" createDate="2011-01-04T22:18:20" nodeName="Ap" path="-1,1057,1076" />
    <node id="1077" parentID="1057" level="2" writerID="0" sortOrder="0" createDate="2011-01-04T22:18:40" nodeName="Mt" path="-1,1057,1077" />
    </root>

  • Jan Skovgaard 11280 posts 23678 karma points MVP 11x admin c-trib
    Feb 22, 2011 @ 21:43
    Jan Skovgaard
    0

    Hi Bart

    But in the XML output you posted in the first post you also only got 2 <node> elements returned, right?

    Are there more than 2 posts tagged with "test"?...

    /Jan

  • Comment author was deleted

    Feb 22, 2011 @ 22:10

    Hi Jan,

    Just checked the output of <xsl:copy-of select="tags:getEverythingWithTags('test')"/> with the xslt viewer and discoverd
    that the node isn't closed correctly

    <root>
    <node id="1076" parentid="1057" level="2" writerid="0" sortorder="7" createdate="2011-01-04T22:18:20" nodename="Ap" path="-1,1057,1076">
    <node id="1077" parentid="1057" level="2" writerid="0" sortorder="0" createdate="2011-01-04T22:18:40" nodename="Mt" path="-1,1057,1077">
    </node>
    </node>
    </root>
    So i am back to zero with the tags:getEverythingWithTags('test') method

    Bart 

  • Jan Skovgaard 11280 posts 23678 karma points MVP 11x admin c-trib
    Feb 22, 2011 @ 22:17
    Jan Skovgaard
    0

    So there should actually be 3 nodes?

    Have you tried to go to the "Content" node and right click it choosing "Republish entire site"? (this updates the XML cache)

    Just to make sure that the XML is properly structured. You could also check to see if there is XML in the umbraco.config that is not wellformed.

    /Jan

  • Chriztian Steinmeier 2800 posts 8790 karma points MVP 8x admin c-trib
    Feb 22, 2011 @ 23:43
    Chriztian Steinmeier
    1

    Hi Bart (& Jan)

    The XSLT Visualizer munges the output - you have to wrap a textarea around stuff you copy-of, in order to see the correct output.

    It seems you're just getting the tagged nodes wrapped in a root element, which means that you should modify your for-each to something like this:

    <xsl:for-each select="tags:getEverythingWithTags('test')/root/node">
        <xsl:value-of select="@nodeName"/>
    </xsl:for-each>

    /Chriztian

     

  • Comment author was deleted

    Feb 23, 2011 @ 19:06

    Hi Chriztian,

    That work fine.

    Thnx a lot

Please Sign in or register to post replies

Write your reply to:

Draft