forum-list.html.twig

Default theme implementation to display a list of forums and containers.

Available variables:

  • forums: A collection of forums and containers to display. It is keyed to the numeric IDs of all child forums and containers. Each forum in forums contains:

    • is_container: A flag indicating if the forum can contain other forums. Otherwise, the forum can only contain topics.
    • depth: How deep the forum is in the current hierarchy.
    • zebra: 'even' or 'odd', used for row class.
    • icon_class: 'default' or 'new', used for forum icon class.
    • icon_title: Text alternative for the forum icon.
    • name: The name of the forum.
    • link: The URL to link to this forum.
    • description: The description field for the forum, containing:
      • value: The descriptive text for the forum.
    • new_topics: A flag indicating if the forum contains unread posts.
    • new_url: A URL to the forum's unread posts.
    • new_text: Text for the above URL, which tells how many new posts.
    • old_topics: A count of posts that have already been read.
    • num_posts: The total number of posts in the forum.
    • last_reply: Text representing the last time a forum was posted or commented in.
  • forum_id: Forum ID for the current forum. Parent to all items within the forums array.

See also

template_preprocess()

template_preprocess_forum_list()

1 theme call to forum-list.html.twig
template_preprocess_forums in drupal/core/modules/forum/forum.module
Prepares variables for forums templates.

File

drupal/core/modules/forum/templates/forum-list.html.twig
View source
  1. {#
  2. /**
  3. * @file
  4. * Default theme implementation to display a list of forums and containers.
  5. *
  6. * Available variables:
  7. * - forums: A collection of forums and containers to display. It is keyed to
  8. * the numeric IDs of all child forums and containers. Each forum in forums
  9. * contains:
  10. * - is_container: A flag indicating if the forum can contain other
  11. * forums. Otherwise, the forum can only contain topics.
  12. * - depth: How deep the forum is in the current hierarchy.
  13. * - zebra: 'even' or 'odd', used for row class.
  14. * - icon_class: 'default' or 'new', used for forum icon class.
  15. * - icon_title: Text alternative for the forum icon.
  16. * - name: The name of the forum.
  17. * - link: The URL to link to this forum.
  18. * - description: The description field for the forum, containing:
  19. * - value: The descriptive text for the forum.
  20. * - new_topics: A flag indicating if the forum contains unread posts.
  21. * - new_url: A URL to the forum's unread posts.
  22. * - new_text: Text for the above URL, which tells how many new posts.
  23. * - old_topics: A count of posts that have already been read.
  24. * - num_posts: The total number of posts in the forum.
  25. * - last_reply: Text representing the last time a forum was posted or
  26. * commented in.
  27. * - forum_id: Forum ID for the current forum. Parent to all items within the
  28. * forums array.
  29. *
  30. * @see template_preprocess()
  31. * @see template_preprocess_forum_list()
  32. *
  33. * @ingroup themeable
  34. */
  35. #}
  36. <table id="forum-{{ forum_id }}">
  37. <thead>
  38. <tr>
  39. <th>{{ 'Forum'|t }}</th>
  40. <th>{{ 'Topics'|t }}</th>
  41. <th>{{ 'Posts'|t }}</th>
  42. <th>{{ 'Last post'|t }}</th>
  43. </tr>
  44. </thead>
  45. <tbody>
  46. {% for child_id, forum in forums %}
  47. <tr id="forum-list-{{ child_id }}" class="{{ forum.zebra }}">
  48. <td {% if forum.is_container == true -%}
  49. colspan="4" class="container"
  50. {%- else -%}
  51. class="forum"
  52. {%- endif -%}>
  53. {#
  54. Enclose the contents of this cell with X divs, where X is the
  55. depth this forum resides at. This will allow us to use CSS
  56. left-margin for indenting.
  57. #}
  58. {% for i in 1..forum.depth if forum.depth > 0 %}<div class="indent">{% endfor %}
  59. <div class="icon forum-status-{{ forum.icon_class }}" title="{{ forum.icon_title }}">
  60. <span class="element-invisible">{{ forum.icon_title }}</span>
  61. </div>
  62. <div class="name"><a href="{{ forum.link }}">{{ forum.label }}</a></div>
  63. {% if forum.description.value %}
  64. <div class="description">{{ forum.description.value }}</div>
  65. {% endif %}
  66. {% for i in 1..forum.depth if forum.depth > 0 %}</div>{% endfor %}
  67. </td>
  68. {% if forum.is_container == false %}
  69. <td class="topics">
  70. {{ forum.num_topics }}
  71. {% if forum.new_topics == true %}
  72. <br />
  73. <a href="{{ forum.new_url }}">{{ forum.new_text }}</a>
  74. {% endif %}
  75. </td>
  76. <td class="posts">{{ forum.num_posts }}</td>
  77. <td class="last-reply">{{ forum.last_reply }}</td>
  78. {% endif %}
  79. </tr>
  80. {% endfor %}
  81. </tbody>
  82. </table>

Related topics