You are here

function archive_page in Drupal 4

Menu callback; lists all nodes posted on a given date.

1 string reference to 'archive_page'
archive_menu in modules/archive.module
Implementation of hook_menu().

File

modules/archive.module, line 219
Displays a calendar to navigate old content.

Code

function archive_page($year = 0, $month = 0, $day = 0) {
  global $user;
  $date = mktime(0, 0, 0, $month, $day, $year) - $user->timezone;
  $date_end = mktime(0, 0, 0, $month, $day + 1, $year) - $user->timezone;

  // Display form.
  $output = archive_browse_form($year, $month, $day);
  if ($year && $month && $day) {

    // Fetch nodes for the selected date, if one was specified.
    $sql = db_rewrite_sql('SELECT n.nid, n.created FROM {node} n WHERE n.status = 1 AND n.created > %d AND n.created < %d ORDER BY n.created');
    $countsql = db_rewrite_sql('SELECT count(n.nid) FROM {node} n WHERE n.status = 1 AND n.created > %d AND n.created < %d ORDER BY n.created');
    $result = pager_query($sql, variable_get('default_nodes_main', 10), 0, $countsql, $date, $date_end);
    if (db_num_rows($result) > 0) {
      while ($nid = db_fetch_object($result)) {
        $output .= node_view(node_load($nid->nid), 1);
      }
      $output .= theme('pager');
    }
    else {
      $output .= theme('box', t('No posts found.'), '');
    }
  }
  else {
    $output .= theme('box', t('No posts found.'), '');
  }
  return $output;
}