Copied to clipboard

Flag this post as spam?

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


  • Martin 278 posts 661 karma points
    Feb 10, 2012 @ 11:19
    Martin
    0

    List News by Month

    Hi all, 

    Im needing some displaying my news items by month.

    Im using the Autofolders package to organise my news items.

    What I have so far is a News page with a macro that lists all news items.

    I also have an Archive macro that lists the year & month. 

    What im trying to do is display all news items inside that month.

    My XSLT for my News macro is 

    <xsl:variable name="siteRoot" select="$currentPage/ancestor-or-self::*[@level = 1]" />
    <xsl:variable name="newsitems" select="$siteRoot/*[@nodeName = 'News']//*[@level = 5][@isDoc]" />    
        
    <xsl:template match="/">
    <!-- The fun starts here -->
    <xsl:for-each select="$newsitems">
    <xsl:sort select="current()/sortDate" order="ascending"/>
    <div class="row">
      <h3 class="newsHeadline">
        <href="{umbraco.library:NiceUrl(@id)}">
          <xsl:value-of select="@nodeName"/>
        </a>
      </h3>
      <h6><xsl:value-of select="umbraco.library:FormatDateTime(sortDate, 'D')"/></h6>
      <p><xsl:value-of select="newsSummary" disable-output-escaping="yes"/></p>
    </div>
        
    </xsl:for-each
    </xsl:template>

     

    The XSLT I have for my year/month archive is 

    <xsl:variable name="siteRoot" select="$currentPage/ancestor-or-self::*[@level = 1]" />
    <xsl:variable name="years" select="$siteRoot/*[@nodeName = 'News']/*[@isDoc]" />
       
    <xsl:template match="/"
        <xsl:variable name="sortDate" select="$currentPage/sortDate/*" /> 
      <div class="four panels alpha">
        <h4>../News Archive</h4>  
        <ul class="archive">
          
        <xsl:for-each select="$years">
         <xsl:sort select="@sortOrder" order="descending" /> 
          <li class="years"
            <xsl:value-of select="@nodeName"/>
            <ul>
              <xsl:for-each select="*[@isDoc]"><!-- Children of the current year are months, right? -->
                <xsl:sort select="umbraco.library:FormatDateTime(sortDate, 'd')" data-type="number" order="ascending"/>
                <li class="months">
                <href="{umbraco.library:NiceUrl(@id)}">
                  <xsl:value-of select="@nodeName"/>
                </a>
              </li>  
              </xsl:for-each>
            </ul>
          </li>  
          </xsl:for-each>
        </ul>
      </div>  
    </xsl:template>   
    </xsl:stylesheet>

    Any help would be grateful.

     

    Martin

     

     

     

     

     

     

     

     

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies