__block--views-block--home-block-1.html.twig 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. {#
  2. /**
  3. * @file
  4. * Default theme implementation to display a block.
  5. *
  6. * Available variables:
  7. * - plugin_id: The ID of the block implementation.
  8. * - label: The configured label of the block if visible.
  9. * - configuration: A list of the block's configuration values.
  10. * - label: The configured label for the block.
  11. * - label_display: The display settings for the label.
  12. * - provider: The module or other provider that provided this block plugin.
  13. * - Block plugin specific settings will also be stored here.
  14. * - in_preview: Whether the plugin is being rendered in preview mode.
  15. * - content: The content of this block.
  16. * - attributes: array of HTML attributes populated by modules, intended to
  17. * be added to the main container tag of this template.
  18. * - id: A valid HTML ID and guaranteed unique.
  19. * - title_attributes: Same as attributes, except applied to the main title
  20. * tag that appears in the template.
  21. * - title_prefix: Additional output populated by modules, intended to be
  22. * displayed in front of the main title tag that appears in the template.
  23. * - title_suffix: Additional output populated by modules, intended to be
  24. * displayed after the main title tag that appears in the template.
  25. *
  26. * @see template_preprocess_block()
  27. *
  28. * @ingroup themeable
  29. */
  30. #}
  31. {%
  32. set classes = [
  33. 'block',
  34. 'block-' ~ configuration.provider|clean_class,
  35. 'block-' ~ plugin_id|clean_class,
  36. ]
  37. %}
  38. <div{{ attributes.addClass(classes) }}>
  39. {{ title_prefix }}
  40. {% if label %}
  41. <h2{{ title_attributes }}>{{ label }}</h2>
  42. {% endif %}
  43. {{ title_suffix }}
  44. <div class="custom-block-content">
  45. {% if content %}
  46. {% set displayed_first_paragraph = false %}
  47. {% for key, item in content %}
  48. {% if item['#markup'] is defined and not displayed_first_paragraph %}
  49. {# Split the content by paragraphs #}
  50. {% set paragraphs = item['#markup']|split('</p>') %}
  51. {# Display the first paragraph only #}
  52. <p>{{ paragraphs[0]|striptags }}</p>
  53. {# Add a "Voir plus" button that links to the full content page #}
  54. <a href="/full-content-page" class="btn btn-primary">Voir plus</a>
  55. {% set displayed_first_paragraph = true %}
  56. {% elseif not displayed_first_paragraph %}
  57. {{ item }}
  58. {% endif %}
  59. {% endfor %}
  60. {% endif %}
  61. </div>
  62. </div>