Copied to clipboard

Flag this post as spam?

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


  • Sam 184 posts 209 karma points
    Oct 12, 2010 @ 19:05
    Sam
    0

    List display events otherwise display no events

    Hi, using v 4.0.4.2 and this is my xslt:

      <ul>
      <xsl:for-each select="$currentPage/ancestor-or-self::node[@level='1']//node[@nodeTypeAlias='EventsPage']">
       <xsl:sort select="umbraco.library:FormatDateTime(data [@alias='EventDate'], 'yyyyMMdd')" data-type="number" order="ascending" />
     

    <xsl:if test="position() &lt;= 5">

    <xsl:choose>

    <xsl:when test="$currentPage/ancestor-or-self::node/@id = current()/@id">
                            <xsl:attribute name="class">
                    <xsl:value-of select="'current'"/>
                            </xsl:attribute>

    <li>
    <a href="{umbraco.library:NiceUrl(@id)}"><xsl:value-of select="@nodeName"/></a>
    </li>

    </xsl:when>

    <xsl:otherwise>
    <li>No events</li>
    </xsl:otherwise>

    </xsl:choose>

    </xsl:if>

    </xsl:for-each>
    </ul>

    I am trying to make the list display 'No events' if there are no nodes under the 'latest news page'. Each sub page is called 'EventsPage'. I can't seem to get it to display correctly, nothing displays at the moment, just an empty list.

    Any help would be much appreciated, thanks in advance :)

    ps I know my xslt is pretty poor still, I don't know in which order I should have the commands etc.

    Sam.

  • Rich Green 2246 posts 4008 karma points
    Oct 13, 2010 @ 08:04
    Rich Green
    1

    Hi Sam,

    Your logic is a little out. You need to do something like this:

    <xsl:choose>
    <xsl:when test="count($currentPage/ancestor-or-self::node[@level='1']/node[@nodeTypeAlias='EventsPage']) &gt; 0">
    
        Display your events here in a loop
    
    </xsl:when>
    <xsl:otherwise>
    
        <ul><li>No events</li></ul>
    
    
    </xsl:otherwise>
    </xsl:choose>

    Rich

  • Sam 184 posts 209 karma points
    Oct 23, 2010 @ 11:38
    Sam
    0

    Thanks Rich,

    Only just got the time to sort this out. Reworked the xslt and it works a charm :)

    Sam.

Please Sign in or register to post replies

Write your reply to:

Draft