You are here

content-calendar.html.twig in Content Planner 8

<div class="content-calendar">

  <div class="calendar-id" id="{{ calendar.calendar_id }}"></div>

  <h2>{{ calendar.label }}</h2>

  <table>
    <thead>
    <tr>
      <th>{{ "Monday"|t }}</th>
      <th>{{ "Tuesday"|t }}</th>
      <th>{{ "Wednesday"|t }}</th>
      <th>{{ "Thursday"|t }}</th>
      <th>{{ "Friday"|t }}</th>
      <th>{{ "Saturday"|t }}</th>
      <th>{{ "Sunday"|t }}</th>
    </tr>

    </thead>

    <tbody>


    {# If the month does not start with a Monday #}
    {% if calendar.days[0].weekday != 1 %}

    {% set cells_previous_month = calendar.days[0].weekday - 1 %}
    <tr>

      {% for i in 1..cells_previous_month %}
        <td class="cell disabled-day">&nbsp;</td>
      {% endfor %}

      {% set item_counter = cells_previous_month %}

      {% else %} {# If the month starts with a Monday #}
        {% set item_counter = 0 %}
      {% endif %}


      {# Loop over the month's days #}
      {% for day in calendar.days %}

      {% set item_counter = item_counter + 1 %}

      {% if item_counter == 1 %}
      <tr>
      {% endif %}

    <td class="cell droppable {% if day.is_today %}today{% endif %}" data-date="{{ day.date }}">
      <span class="day">{{ day.day }}</span>

      <div class="add-content">
        <div class="add-button">+</div>
        <span class="add-content-label">{{ "Add Content"|t }}</span>
        <ul class="actions">

          {% for entity_key, content_type_entity in node_type_creation_permissions %}
            <li>
                  <span class="label">
                    <a href="{{ path('node.add', {'node_type': entity_key}) }}?destination={{ path('content_calendar.calendar_redirect', {'year': calendar.year, 'month': calendar.month}) }}&publish_on={{ day.date }}">{{ content_type_entity.label }}</a>
                  </span>
            </li>
          {% endfor %}
        </ul>
      </div>


      {% for node in day.nodes %}
        {{ node }}
      {% endfor %}
    </td>

    {% if item_counter == 7 %}
      </tr>
      {% set item_counter = 0 %}
    {% endif %}

    {% endfor %}

    {# If the last day of the month is not on a sunday, then use the rest of the cells as padding #}
    {% if item_counter != 7 %}

      {% set cells_next_month = 7 - item_counter %}

      {% for i in 1..cells_next_month %}
        <td class="cell disabled-day">&nbsp;</td>
      {% endfor %}
      </tr>
    {% endif %}

    </tbody>

  </table>

  {{ legend }}

</div>

File

modules/content_calendar/templates/content-calendar.html.twig
View source
  1. <div class="content-calendar">
  2. <div class="calendar-id" id="{{ calendar.calendar_id }}"></div>
  3. <h2>{{ calendar.label }}</h2>
  4. <table>
  5. <thead>
  6. <tr>
  7. <th>{{ "Monday"|t }}</th>
  8. <th>{{ "Tuesday"|t }}</th>
  9. <th>{{ "Wednesday"|t }}</th>
  10. <th>{{ "Thursday"|t }}</th>
  11. <th>{{ "Friday"|t }}</th>
  12. <th>{{ "Saturday"|t }}</th>
  13. <th>{{ "Sunday"|t }}</th>
  14. </tr>
  15. </thead>
  16. <tbody>
  17. {# If the month does not start with a Monday #}
  18. {% if calendar.days[0].weekday != 1 %}
  19. {% set cells_previous_month = calendar.days[0].weekday - 1 %}
  20. <tr>
  21. {% for i in 1..cells_previous_month %}
  22. <td class="cell disabled-day">&nbsp;</td>
  23. {% endfor %}
  24. {% set item_counter = cells_previous_month %}
  25. {% else %} {# If the month starts with a Monday #}
  26. {% set item_counter = 0 %}
  27. {% endif %}
  28. {# Loop over the month's days #}
  29. {% for day in calendar.days %}
  30. {% set item_counter = item_counter + 1 %}
  31. {% if item_counter == 1 %}
  32. <tr>
  33. {% endif %}
  34. <td class="cell droppable {% if day.is_today %}today{% endif %}" data-date="{{ day.date }}">
  35. <span class="day">{{ day.day }}</span>
  36. <div class="add-content">
  37. <div class="add-button">+</div>
  38. <span class="add-content-label">{{ "Add Content"|t }}</span>
  39. <ul class="actions">
  40. {% for entity_key, content_type_entity in node_type_creation_permissions %}
  41. <li>
  42. <span class="label">
  43. <a href="{{ path('node.add', {'node_type': entity_key}) }}?destination={{ path('content_calendar.calendar_redirect', {'year': calendar.year, 'month': calendar.month}) }}&publish_on={{ day.date }}">{{ content_type_entity.label }}</a>
  44. </span>
  45. </li>
  46. {% endfor %}
  47. </ul>
  48. </div>
  49. {% for node in day.nodes %}
  50. {{ node }}
  51. {% endfor %}
  52. </td>
  53. {% if item_counter == 7 %}
  54. </tr>
  55. {% set item_counter = 0 %}
  56. {% endif %}
  57. {% endfor %}
  58. {# If the last day of the month is not on a sunday, then use the rest of the cells as padding #}
  59. {% if item_counter != 7 %}
  60. {% set cells_next_month = 7 - item_counter %}
  61. {% for i in 1..cells_next_month %}
  62. <td class="cell disabled-day">&nbsp;</td>
  63. {% endfor %}
  64. </tr>
  65. {% endif %}
  66. </tbody>
  67. </table>
  68. {{ legend }}
  69. </div>