Same name and namespace in other branches
  1. 4.6.x modules/forum.module \theme_forum_display()
  2. 4.7.x modules/forum.module \theme_forum_display()

Format the forum body.

Related topics

1 theme call to theme_forum_display()
forum_page in modules/forum/forum.module
Menu callback; prints a forum listing.

File

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

Code

function theme_forum_display($forums, $topics, $parents, $tid, $sortby, $forum_per_page) {
  global $user;

  // forum list, topics list, topic browser and 'add new topic' link
  $vocabulary = taxonomy_get_vocabulary(variable_get('forum_nav_vocabulary', ''));
  $title = $vocabulary->name;

  // Breadcrumb navigation:
  $breadcrumb = array();
  if ($tid) {
    $breadcrumb[] = array(
      'path' => 'forum',
      'title' => $title,
    );
  }
  if ($parents) {
    $parents = array_reverse($parents);
    foreach ($parents as $p) {
      if ($p->tid == $tid) {
        $title = $p->name;
      }
      else {
        $breadcrumb[] = array(
          'path' => 'forum/' . $p->tid,
          'title' => $p->name,
        );
      }
    }
  }
  drupal_set_title(check_plain($title));
  $breadcrumb[] = array(
    'path' => $_GET['q'],
  );
  menu_set_location($breadcrumb);
  if (count($forums) || count($parents)) {
    $output = '<div id="forum">';
    $output .= '<ul>';
    if (user_access('create forum topics')) {
      $output .= '<li>' . l(t('Post new forum topic.'), "node/add/forum/{$tid}") . '</li>';
    }
    else {
      if ($user->uid) {
        $output .= '<li>' . t('You are not allowed to post a new forum topic.') . '</li>';
      }
      else {
        $output .= '<li>' . t('<a href="@login">Login</a> to post a new forum topic.', array(
          '@login' => url('user/login', drupal_get_destination()),
        )) . '</li>';
      }
    }
    $output .= '</ul>';
    $output .= theme('forum_list', $forums, $parents, $tid);
    if ($tid && !in_array($tid, variable_get('forum_containers', array()))) {
      $output .= theme('forum_topic_list', $tid, $topics, $sortby, $forum_per_page);
      drupal_add_feed(url('taxonomy/term/' . $tid . '/0/feed'), 'RSS - ' . $title);
    }
    $output .= '</div>';
  }
  else {
    drupal_set_title(t('No forums defined'));
    $output = '';
  }
  return $output;
}