You are here

function template_preprocess_forum_list in Drupal 6

Same name and namespace in other branches
  1. 8 core/modules/forum/forum.module \template_preprocess_forum_list()
  2. 7 modules/forum/forum.module \template_preprocess_forum_list()
  3. 9 core/modules/forum/forum.module \template_preprocess_forum_list()

Process variables to format a forum listing.

$variables contains the following information:

  • $forums
  • $parents
  • $tid

See also

forum-list.tpl.php

theme_forum_list()

File

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

Code

function template_preprocess_forum_list(&$variables) {
  global $user;
  $row = 0;

  // Sanitize each forum so that the template can safely print the data.
  foreach ($variables['forums'] as $id => $forum) {
    $variables['forums'][$id]->description = !empty($forum->description) ? filter_xss_admin($forum->description) : '';
    $variables['forums'][$id]->link = url("forum/{$forum->tid}");
    $variables['forums'][$id]->name = check_plain($forum->name);
    $variables['forums'][$id]->is_container = !empty($forum->container);
    $variables['forums'][$id]->zebra = $row % 2 == 0 ? 'odd' : 'even';
    $row++;
    $variables['forums'][$id]->new_text = '';
    $variables['forums'][$id]->new_url = '';
    $variables['forums'][$id]->new_topics = 0;
    $variables['forums'][$id]->old_topics = $forum->num_topics;
    if ($user->uid) {
      $variables['forums'][$id]->new_topics = _forum_topics_unread($forum->tid, $user->uid);
      if ($variables['forums'][$id]->new_topics) {
        $variables['forums'][$id]->new_text = format_plural($variables['forums'][$id]->new_topics, '1 new', '@count new');
        $variables['forums'][$id]->new_url = url("forum/{$forum->tid}", array(
          'fragment' => 'new',
        ));
      }
      $variables['forums'][$id]->old_topics = $forum->num_topics - $variables['forums'][$id]->new_topics;
    }
    $variables['forums'][$id]->last_reply = theme('forum_submitted', $forum->last_post);
  }

  // Give meaning to $tid for themers. $tid actually stands for term id.
  $variables['forum_id'] = $variables['tid'];
  unset($variables['tid']);
}