templates/default/components/organisms/story-grid/story-grid.html.twig line 1

Open in your IDE?
  1. {% set id = id|default(_uid|default(uniqid())) %}
  2. {% set storyObjects = story_objects|default([]) %}
  3. {% set topics = article_topics|default([]) %}
  4. {% set types = article_types|default([]) %}
  5. {% set filteredTopics = app.request.get('topics_' ~ id)|default(filteredTopics|default([])) %}
  6. {% set filteredTypes = app.request.get('types_' ~ id)|default(filteredTypes|default([])) %}
  7. {% set layout = layout|default('classic') %}
  8. {% set storyIds = stories|default([]) %}
  9. {% set limit = article_count|default(storyIds|length) %}
  10. {% if storyObjects is empty%}
  11. {% set storyObjects = getContentByTopicsAndTypes(filteredTopics, filteredTypes, limit, 1, storyIds) %}
  12. {% endif%}
  13. {% if topics is empty and types is empty and (showTopicFilter|default(false) or showTypeFilter|default(false))%}
  14. {% set allStoryObjects = getContentByTopicsAndTypes(topics, types, 50, 1, storyIds) %}
  15. {% set topics = getContentsFilterOptions(allStoryObjects, 'article_topics') %}
  16. {% set types = getContentsFilterOptions(allStoryObjects, 'article_types') %}
  17. {% endif %}
  18. {% set total = storyObjects.total %}
  19. {% set topics = topicFilterOptions|default(topics) %}
  20. {% set types = typeFilterOptions|default(types) %}
  21. {% set dynamicFilterOption = dynamicFilterOption|default("none") %}
  22. {% set background = background|default('gradient-grey-white-grey') %}
  23. <div class="story-grid story-grid--{{ background }}"
  24. data-story-grid-id="{{ id }}"
  25. data-story-grid-story-ids="{{ storyIds|json_encode }}"
  26. data-story-grid-dynamic-filter-option="{{ dynamicFilterOption }}"
  27. data-story-grid-topics="{{ topics|json_encode }}"
  28. data-story-grid-types="{{ types|json_encode }}"
  29. data-story-grid-limit="{{ limit }}"
  30. data-story-grid-layout="{{ layout }}"
  31. data-story-grid-ajax-url="{{ path('app_story_grid') }}"
  32. data-story-grid-ignored-stories="{{ ignoredStories|default }}"
  33. >
  34. {% if headline is defined %}
  35. {{ render_storyblok(headline, {
  36. class: 'headline--center',
  37. }) }}
  38. {% endif %}
  39. {% if showTopicFilter|default(false) or showTypeFilter|default(false) %}
  40. <div class="story-grid__filter-container">
  41. {% if showTopicFilter|default(false) %}
  42. <toggle
  43. trigger-text="{{ 'story_grid_topics'|trans }}"
  44. toggled-media-query="{% if app.request.get('topics_' ~ id)|length %}all{% else %}(min-width: 768px){% endif %}"
  45. >
  46. {% set topicTranslations = 'article_topics'|trans([], 'json')|json_decode %}
  47. <height-transition>
  48. <ul class="story-grid__filter-list story-grid__filter-list-topics">
  49. {% for topic in topics %}
  50. <li data-story-grid-topic="{{ topic }}"
  51. data-reserve-bold-space="{{ topicTranslations[topic]|default(topic) }}"
  52. class="story-grid__filter {% if topic in filteredTopics %}story-grid__filter--active{% endif %}"
  53. tabindex="0"
  54. >
  55. {{ topicTranslations[topic]|default(topic) }}
  56. </li>
  57. {% endfor %}
  58. <li data-story-grid-reset="topics"
  59. data-reserve-bold-space="{{ 'listing_filter_active_filter_reset'|trans }}"
  60. class="story-grid__filter story-grid__filter--reset {% if filteredTopics|length %}story-grid__filter--reset-active{% endif %}"
  61. tabindex="0"
  62. >
  63. {{ 'listing_filter_active_filter_reset'|trans }}
  64. </li>
  65. </ul>
  66. </height-transition>
  67. </toggle>
  68. {% endif %}
  69. {% if showTypeFilter|default(false) %}
  70. <toggle
  71. trigger-text="{{ 'story_grid_types'|trans }}"
  72. toggled-media-query="{% if app.request.get('types_' ~ id)|length %}all{% else %}(min-width: 768px){% endif %}"
  73. >
  74. {% set typeTranslations = 'article_types'|trans([], 'json')|json_decode %}
  75. <height-transition>
  76. <ul class="story-grid__filter-list story-grid__filter-list-types">
  77. {% for type in types %}
  78. <li data-story-grid-type="{{ type }}"
  79. data-reserve-bold-space="{{ typeTranslations[type]|default(type) }}"
  80. class="story-grid__filter {% if type in filteredTypes %}story-grid__filter--active{% endif %}"
  81. tabindex="0"
  82. >
  83. {{ typeTranslations[type]|default(type) }}
  84. </li>
  85. {% endfor %}
  86. <li data-story-grid-reset="types"
  87. data-reserve-bold-space="{{ 'listing_filter_active_filter_reset'|trans }}"
  88. class="story-grid__filter story-grid__filter--reset {% if filteredTypes|length %}story-grid__filter--reset-active{% endif %}"
  89. tabindex="0"
  90. >
  91. {{ 'listing_filter_active_filter_reset'|trans }}
  92. </li>
  93. </ul>
  94. </height-transition>
  95. </toggle>
  96. {% endif %}
  97. </div>
  98. <hr>
  99. {% endif %}
  100. <height-transition>
  101. <div class="story-grid__grid" id="{{ id }}">
  102. {% include 'components/organisms/story-grid/list.html.twig' %}
  103. </div>
  104. </height-transition>
  105. {% set showMore = total > limit %}
  106. {% if link is not empty %}
  107. <div class="story-grid__link">
  108. {{ render_storyblok(link, {
  109. class: 'text-link--primary button button--multitool button--width-auto button--transparent',
  110. }) }}
  111. </div>
  112. {% elseif showMore %}
  113. <div class="story-grid__link">
  114. {% include 'components/atoms/button/button.html.twig' with {
  115. class: 'button button--multitool button--width-auto button--transparent story-grid__button story-grid__button--active',
  116. content: 'pagination_more_text'|trans,
  117. attributes: {
  118. 'data-reserve-bold-space':'pagination_more_text'|trans,
  119. 'data-story-grid-more': 'true',
  120. 'data-story-grid-url': path('app_story_grid')
  121. }
  122. } %}
  123. <span data-story-grid-link-info="{{ 'story_grid_link_info'|trans }}" class="story-grid__link-info story-grid__link-info--active">
  124. {{ 'story_grid_link_info'|trans({'%loaded%': min(limit, total), '%total%': total}) }}
  125. </span>
  126. </div>
  127. {% endif %}
  128. </div>