Вы здесь

Друпал 7: forum-list.tpl.php

forum-list.tpl.php — шаблон формирующий список форумов и контейнеров.

Переменные

  • $forums — массив форумов и контейнеров (вложенные форумы и контейнеры снабжены ключами, которые представляют из себя числовые идентификаторы)
  • $forum_id— идентификатор текущего форума. Parent to all items within the $forums array.

Содержание каждой переменной $forum в переменной $forums

  • $forum->depth — глубина форума в текущей иерархии
  • $forum->description — описание форума
  • $forum->is_container — возвращает значение 1 (TRUE, если это контейнер) или 0 (FALSE, если это форум)
  • $forum->last_reply — время добавления последней темы или комментария (ответа)
  • $forum->link — ссылка на форум
  • $forum->name — название форума
  • $forum->num_posts — общее количество сообщений в форуме
  • $forum->new_text — текст, информирующий о непрочитанных темах форумов
  • $forum->new_topics — возвращает значение 1 (TRUE, если форум содержит непрочитанные темы) или 0 (FALSE, если форум не содержит непрочитанные темы)
  • $forum->new_url — ссылка на непрочитанные темы форумов
  • $forum->old_topics — счётчик прочитанных сообщений
  • $forum->zebra — добавление классов odd и even (используется для оформления с помощью CSS)

Пример шаблона

<table id="forum-<?php print $forum_id; ?>">
  <thead>
    <tr>
      <th><?php print t('Forum'); ?></th>
      <th><?php print t('Topics');?></th>
      <th><?php print t('Posts'); ?></th>
      <th><?php print t('Last post'); ?></th>
    </tr>
  </thead>
  <tbody>
  <?php foreach ($forums as $child_id => $forum): ?>
    <tr id="forum-list-<?php print $child_id; ?>" class="<?php print $forum->zebra; ?>">
      <td <?php print $forum->is_container ? 'colspan="4" class="container"' : 'class="forum"'; ?>>
        <?php /* Enclose the contents of this cell with X divs, where X is the
               * depth this forum resides at. This will allow us to use CSS
               * left-margin for indenting.
               */
?>

        <?php print str_repeat('<div class="indent">', $forum->depth); ?>
          <div class="name"><a href="<?php print $forum->link; ?>"><?php print $forum->name; ?></a></div>
          <?php if ($forum->description): ?>
            <div class="description"><?php print $forum->description; ?></div>
          <?php endif; ?>
        <?php print str_repeat('</div>', $forum->depth); ?>
      </td>
      <?php if (!$forum->is_container): ?>
        <td class="topics">
          <?php print $forum->num_topics ?>
          <?php if ($forum->new_topics): ?>
            <br />
            <a href="<?php print $forum->new_url; ?>"><?php print $forum->new_text; ?></a>
          <?php endif; ?>
        </td>
        <td class="posts"><?php print $forum->num_posts ?></td>
        <td class="last-reply"><?php print $forum->last_reply ?></td>
      <?php endif; ?>
    </tr>
  <?php endforeach; ?>
  </tbody>
</table>