Copied to clipboard

Flag this post as spam?

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


  • Daniel 19 posts 51 karma points
    Sep 02, 2011 @ 11:41
    Daniel
    0

    Retrieve field from inside each node in loop

    Hi!

    This is part of my loop to list the 5 latest news:

    <xsl:for-each select="current()/* [@isDoc and string(showInNavigation) != '1']">
    <xsl:sort select="@createDate" order="descending" />
              <xsl:if test="position() &lt;= $numberOfItems">
    <li>
    <!--<a href="{umbraco.library:NiceUrl(@id)}">-->
    <xsl:if test="$currentPage/@id = current()/@id">
    <xsl:attribute name="class">Selected</xsl:attribute>
    </xsl:if>
    Nodnamn: <xsl:value-of select="@nodeName"/>
    <!--</a>-->
    <xsl:if test="count(current()/* [@isDoc and string(showInNavigation) != '1']) &gt; '0'">
    <xsl:call-template name="submenu">
    <xsl:with-param name="level" select="$level+1"/>
    </xsl:call-template>
    </xsl:if>
    </li>
      </xsl:if>
      </xsl:for-each>

    Is it possible to retrieve information from inside each node? Right now all it does is to list the 5 latest node names. But I'd also like to get the field called newsText from each node. Is it possible?

    I'd love all the help I can get! :)

  • Fuji Kusaka 2203 posts 4220 karma points
    Sep 02, 2011 @ 11:56
    Fuji Kusaka
    0

    Hi Daniel,

    You can call your document field type inside your loop so that each node will also display what you entered depending on the content.

    Simply call your document type field alias by clicking on the button on top or your dashboard in your corresponding xslt (insert xsl:value-of)

    <xsl:for-eachselect="current()/* [@isDoc and string(showInNavigation) != '1']">
    <xsl:sortselect="@createDate"order="descending"/>
              <xsl:iftest="position() &lt;= $numberOfItems">
    <li>
    <!--<a href="{umbraco.library:NiceUrl(@id)}">-->
    <xsl:iftest="$currentPage/@id = current()/@id">
    <xsl:attributename="class">Selected</xsl:attribute>
    </xsl:if>
    Nodnamn: <xsl:value-ofselect="@nodeName"/> <
    <!-- Your Value Here -->
       <xsl:value-of select="newsText"/> 
    <!--</a>-->
    <xsl:iftest="count(current()/* [@isDoc and string(showInNavigation) != '1']) &gt; '0'">
    <xsl:call-templatename="submenu">
    <xsl:with-paramname="level"select="$level+1"/>
    </xsl:call-template>
    </xsl:if>
    </li>
      </xsl:if>
      </xsl:for-each>

     

    Hope this helps

  • Daniel 19 posts 51 karma points
    Sep 02, 2011 @ 12:16
    Daniel
    0

    Great, it works

    I tried @newsText inside my xsl-value but I should've used your way of course. Thanks for your help!

  • Fuji Kusaka 2203 posts 4220 karma points
    Sep 02, 2011 @ 12:19
    Fuji Kusaka
    0

    Glad i could help

     

    //fuji

  • Fuji Kusaka 2203 posts 4220 karma points
    Sep 02, 2011 @ 12:19
    Fuji Kusaka
    0

    Glad i could help

     

    //fuji

Please Sign in or register to post replies

Write your reply to:

Draft