News Archive Pages

We plan to show the latest news releases on the site's home page. We would also like members (not the public) to be able to look at past news releases. This was accompilshed as follows:

  • Created a Drupal View called News Archive:
    • Selects all published nodes of type News Item
    • Sorts in reverse chronological order (i.e. newest items appear first)
    • Show 10 items per screen, with a "pager" at the bottom to let the user navigate between pages
    • A contextual filter for the year in which the item was created. This facilitates viewing items for a single year, e.g. 2003. (More on this below.)

       
  • Created a block called News Archive Years with the following mix of PHP and HTML:
    • <a href="/news-archive"> All </a>
      <?php
      for ($i = date("Y"); $i >= 2001; $i--) {
        print("&nbsp;&ndash;&nbsp;<a href='/news-archive/$i'>$i</a>");
      }
      ?>
    • In a nutshell, the code above outputs a hyperlink for viewing all years, then another link for each year between the present and 2001 (working backwards).
    • Configured the block so that it only appears on pages that begin with news-archive
    • Positioned the block above the page content

Net result: https://www.iac.org/news-archive shows all news items.  URLs like https://www.iac.org/news-archive/2007 show all news items from 2007.