theme_forum_display

5 forum.module theme_forum_display($forums, $topics, $parents, $tid, $sortby, $forum_per_page)

Format the forum body.

Related topics

1 theme call to theme_forum_display()

File

modules/forum.module, line 754
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 (module_exist('tracker')) {
      if ($user->uid) {
        $output .= ' <li>' . l(t('My forum discussions.'), "tracker/$user->uid") . '</li>';
      }

      $output .= ' <li>' . l(t('Active forum discussions.'), 'tracker') . '</li>';
    }

    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'))) . '</li>';
    }
    $output .= '</ul>';

    $output .= theme('forum_list', $forums, $parents, $tid);

    if ($tid && !in_array($tid, variable_get('forum_containers', array()))) {
      drupal_add_link(array(
        'rel' => 'alternate', 
        'type' => 'application/rss+xml', 
        'title' => 'RSS - ' . $title, 
        'href' => url('taxonomy/term/' . $tid . '/0/feed'),
      ));

      $output .= theme('forum_topic_list', $tid, $topics, $sortby, $forum_per_page);
      $output .= theme('xml_icon', url("taxonomy/term/$tid/0/feed"));
    }
    $output .= '</div>';
  }
  else {
    drupal_set_title(t('No forums defined'));
    $output = '';
  }

  return $output;
}
Login or register to post comments