You are here

function theme_forum_topic_navigation in Drupal 4

Same name and namespace in other branches
  1. 5 modules/forum/forum.module \theme_forum_topic_navigation()

Format the next/previous forum topic navigation links.

Related topics

1 theme call to theme_forum_topic_navigation()
forum_view in modules/forum.module
Implementation of hook_view().

File

modules/forum.module, line 1050
Enable threaded discussions about general topics.

Code

function theme_forum_topic_navigation($node) {
  $output = '';

  // get previous and next topic
  $sql = "SELECT n.nid, n.title, n.sticky, l.comment_count, l.last_comment_timestamp FROM {node} n INNER JOIN {node_comment_statistics} l ON n.nid = l.nid INNER JOIN {term_node} r ON n.nid = r.nid AND r.tid = %d WHERE n.status = 1 AND n.type = 'forum' ORDER BY n.sticky DESC, " . _forum_get_topic_order_sql(variable_get('forum_order', 1));
  $result = db_query(db_rewrite_sql($sql), $node->tid);
  while ($topic = db_fetch_object($result)) {
    if ($stop == 1) {
      $next = new StdClass();
      $next->nid = $topic->nid;
      $next->title = $topic->title;
      break;
    }
    if ($topic->nid == $node->nid) {
      $stop = 1;
    }
    else {
      $prev = new StdClass();
      $prev->nid = $topic->nid;
      $prev->title = $topic->title;
    }
  }
  if ($prev || $next) {
    $output .= '<div class="forum-topic-navigation">';
    if ($prev) {
      $output .= l(t('‹ ') . $prev->title, 'node/' . $prev->nid, array(
        'class' => 'topic-previous',
        'title' => t('Go to previous forum topic'),
      ));
    }
    if ($prev && $next) {

      // Word break (a is an inline element)
      $output .= ' ';
    }
    if ($next) {
      $output .= l($next->title . t(' ›'), 'node/' . $next->nid, array(
        'class' => 'topic-next',
        'title' => t('Go to next forum topic'),
      ));
    }
    $output .= '<br class="clear" /></div>';
  }
  return $output;
}