You are here

forum-list.html.twig in Drupal 10

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.

File

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

Related topics