You are here

calendar-week.html.twig in Calendar 8

Same filename and directory in other branches
  1. 8.2 templates/calendar-week.html.twig

Template to display a view as a calendar week.

Available variables:

  • day_names: An array of the day of week names for the table header.
  • rows: The rendered data for this week.

For each day of the week, you have:

  • rows['date'] - the date for this day, formatted as YYYY-MM-DD.
  • rows['datebox'] - the formatted datebox for this day.
  • rows['empty'] - empty text for this day, if no items were found.
  • rows['all_day'] - an array of formatted all day items.
  • rows['items'] - an array of timed items for the day.
  • rows['items'][$time_period]['hour'] - the formatted hour for a time period.
  • rows['items'][$time_period]['ampm'] - the formatted ampm value, if any for a time period.
  • rows['items'][$time_period]['values'] - An array of formatted items for a time period.

File

templates/calendar-week.html.twig
View source
  1. {#
  2. /**
  3. * @file
  4. * Template to display a view as a calendar week.
  5. *
  6. * Available variables:
  7. * - day_names: An array of the day of week names for the table header.
  8. * - rows: The rendered data for this week.
  9. *
  10. * For each day of the week, you have:
  11. * - rows['date'] - the date for this day, formatted as YYYY-MM-DD.
  12. * - rows['datebox'] - the formatted datebox for this day.
  13. * - rows['empty'] - empty text for this day, if no items were found.
  14. * - rows['all_day'] - an array of formatted all day items.
  15. * - rows['items'] - an array of timed items for the day.
  16. * - rows['items'][$time_period]['hour'] - the formatted hour for a time period.
  17. * - rows['items'][$time_period]['ampm'] - the formatted ampm value, if any for a time period.
  18. * - rows['items'][$time_period]['values'] - An array of formatted items for a time period.
  19. *
  20. * @see template_preprocess_calendar_week()
  21. *
  22. * @ingroup themeable
  23. */
  24. #}
  25. <div class="calendar-calendar"><div class="week-view">
  26. <table class="full">
  27. <thead>
  28. <tr>
  29. {% if by_hour_content > 0 or start_times is not empty %}
  30. <th class="calendar-agenda-hour">{% trans %}Time{% endtrans %}</th>
  31. {% endif %}
  32. {% for cell in day_names %}
  33. <th class="{{ cell.class }}" id="{{ cell.header_id }}">
  34. {{ cell.data }}
  35. </th>
  36. {% endfor %}
  37. </tr>
  38. </thead>
  39. <tbody>
  40. {% for i in 0..multiday_rows %}
  41. {% set row_class = 'all-day' %}
  42. {% if loop.first %}{% set row_class_extra = 'first' %}{% endif %}
  43. {% if loop.last %}{% set row_class_extra = 'last' %}{% endif %}
  44. <tr class="{{ row_class }} {{ row_class_extra }}">
  45. {% if loop.index == 0 and (by_hour_count > 0 or start_times is not empty) %}
  46. <td class="{{ agenda_hour_class }}" rowspan="{{ multiday_rows }}">
  47. <span class="calendar-hour">{% trans with {'context': 'datetime'} %}All day{% endtrans %}</span>
  48. </td>
  49. {% endif %}
  50. {% set colpos = 0 %}
  51. {% for j in 0..6 %}
  52. {% set cell = all_day[j][i] %}
  53. {% if cell is not empty and cell.filled and cell['wday'] == j %}
  54. {% for k in colpos..cell['wday'] %}
  55. <td class="multi-day no-entry"><div class="inner">&nbsp;</div></td>
  56. {% endfor %}
  57. <td colspan="{{ cell['colspan'] }}" class="multi-day">
  58. <div class="inner">
  59. {{ cell.entry }}
  60. </div>
  61. </td>
  62. {% set colpos = cell['wday'] + cell['colspan'] + 1 %}
  63. {% endif %}
  64. {% endfor %}
  65. {% for j in colpos..6 %}
  66. <td class="multi-day no-entry"><div class="inner">&nbsp;</div></td>
  67. {% endfor %}
  68. </tr>
  69. {% endfor %}
  70. {% for time in items %}
  71. <tr class="not-all-day">
  72. <td class="calendar-agenda-hour">
  73. <span class="calendar-hour">{{ time.hour }}</span><span class="calendar-ampm">{{ time.ampm }}</span>
  74. </td>
  75. {% set current_position = 0 %}
  76. {% for column in columns %}
  77. {% set column_position = time.values.column[0] ? time.values.column[0].wday : loop.index %}
  78. {% for i in column_position %}
  79. <td class="calendar-agenda-items single-day">
  80. <div class="calendar">
  81. <div class="inner">&nbsp</div>
  82. </div>
  83. </td>
  84. {% endfor %}
  85. {% set current_position = column_position + 1 %}
  86. <td class="calendar-agenda-items single-day" headers="{{ header_ids[loop.index - 1] }}">
  87. <div class="calendar">
  88. <div class="inner">
  89. {% for item in time.values[column] %}
  90. {{ item.entry }}
  91. {% endfor %}
  92. </div>
  93. </div>
  94. </td>
  95. {% endfor %}
  96. {% if current_position < 7 %}
  97. {% for i in current_position..6 %}
  98. <td class="calendar-agenda-items single-day">
  99. <div class="calendar">
  100. <div class="inner">&nbsp</div>
  101. </div>
  102. </td>
  103. {% endfor %}
  104. {% endif %}
  105. </tr>
  106. {% endfor %}
  107. </tbody>
  108. </table>
  109. </div></div>