forum-list.html.twig

Same filename in this branch
  1. 8.9.x core/themes/seven/templates/classy/dataset/forum-list.html.twig
  2. 8.9.x core/themes/claro/templates/classy/dataset/forum-list.html.twig
  3. 8.9.x core/themes/bartik/templates/classy/dataset/forum-list.html.twig
  4. 8.9.x core/themes/stable/templates/dataset/forum-list.html.twig
  5. 8.9.x core/themes/classy/templates/dataset/forum-list.html.twig
  6. 8.9.x core/modules/forum/templates/forum-list.html.twig
Same filename in other branches
  1. 9 core/profiles/demo_umami/themes/umami/templates/classy/dataset/forum-list.html.twig
  2. 9 core/themes/olivero/templates/dataset/forum-list.html.twig
  3. 9 core/themes/stable9/templates/dataset/forum-list.html.twig
  4. 9 core/themes/seven/templates/classy/dataset/forum-list.html.twig
  5. 9 core/themes/claro/templates/classy/dataset/forum-list.html.twig
  6. 9 core/themes/bartik/templates/classy/dataset/forum-list.html.twig
  7. 9 core/themes/stable/templates/dataset/forum-list.html.twig
  8. 9 core/themes/classy/templates/dataset/forum-list.html.twig
  9. 9 core/modules/forum/templates/forum-list.html.twig
  10. 10 core/profiles/demo_umami/themes/umami/templates/classy/dataset/forum-list.html.twig
  11. 10 core/themes/olivero/templates/dataset/forum-list.html.twig
  12. 10 core/themes/stable9/templates/dataset/forum-list.html.twig
  13. 10 core/themes/claro/templates/classy/dataset/forum-list.html.twig
  14. 10 core/modules/forum/templates/forum-list.html.twig
  15. 11.x core/profiles/demo_umami/themes/umami/templates/classy/dataset/forum-list.html.twig
  16. 11.x core/themes/olivero/templates/dataset/forum-list.html.twig
  17. 11.x core/themes/stable9/templates/dataset/forum-list.html.twig
  18. 11.x core/themes/claro/templates/classy/dataset/forum-list.html.twig
  19. 11.x core/modules/forum/templates/forum-list.html.twig

Theme override 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_forum_list()

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

File

core/profiles/demo_umami/themes/umami/templates/classy/dataset/forum-list.html.twig

View source
  1. {#
  2. /**
  3. * @file
  4. * Theme override 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_forum_list()
  31. */
  32. #}
  33. <table id="forum-{{ forum_id }}">
  34. <thead>
  35. <tr>
  36. <th>{{ 'Forum'|t }}</th>
  37. <th>{{ 'Topics'|t }}</th>
  38. <th>{{ 'Posts'|t }}</th>
  39. <th>{{ 'Last post'|t }}</th>
  40. </tr>
  41. </thead>
  42. <tbody>
  43. {% for child_id, forum in forums %}
  44. <tr id="forum-list-{{ child_id }}" class="{{ forum.zebra }}">
  45. <td {% if forum.is_container == true -%}
  46. colspan="4" class="container"
  47. {%- else -%}
  48. class="forum-list__forum"
  49. {%- endif -%}>
  50. {#
  51. Enclose the contents of this cell with X divs, where X is the
  52. depth this forum resides at. This will allow us to use CSS
  53. left-margin for indenting.
  54. #}
  55. {% for i in 1..forum.depth if forum.depth > 0 %}<div class="indented">{% endfor %}
  56. <div class="forum__icon forum-status-{{ forum.icon_class }}" title="{{ forum.icon_title }}">
  57. <span class="visually-hidden">{{ forum.icon_title }}</span>
  58. </div>
  59. <div class="forum__name"><a href="{{ forum.link }}">{{ forum.label }}</a></div>
  60. {% if forum.description.value %}
  61. <div class="forum__description">{{ forum.description.value }}</div>
  62. {% endif %}
  63. {% for i in 1..forum.depth if forum.depth > 0 %}</div>{% endfor %}
  64. </td>
  65. {% if forum.is_container == false %}
  66. <td class="forum__topics">
  67. {{ forum.num_topics }}
  68. {% if forum.new_topics == true %}
  69. <br />
  70. <a href="{{ forum.new_url }}">{{ forum.new_text }}</a>
  71. {% endif %}
  72. </td>
  73. <td class="forum__posts">{{ forum.num_posts }}</td>
  74. <td class="forum__last-reply">{{ forum.last_reply }}</td>
  75. {% endif %}
  76. </tr>
  77. {% endfor %}
  78. </tbody>
  79. </table>

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.