vendor/shopware/storefront/Resources/views/storefront/utilities/alert.html.twig line 1

  1. {#
  2. Global messages template
  3. https://getbootstrap.com/docs/5.2/components/alerts
  4. *Type:
  5. The template provides an easy way to display messages in the storefront. The following types are supported:
  6. * primary
  7. * secondary
  8. * danger (red)
  9. * success (green)
  10. * warning (yellow)
  11. * info (blue)
  12. * light (white)
  13. * dark (dark gray)
  14.     {% sw_include '@Storefront/storefront/utilities/alert.html.twig' with {
  15.         type:"primary",
  16.         content:"Primary Lorem ipsum dolor"
  17.     } %}
  18. *Icons:
  19. Icons are shown by default. To hide the icon within the alert, set the value of "icon" to false:
  20.     {% sw_include '@Storefront/storefront/utilities/alert.html.twig' with {
  21.         type:"primary",
  22.         content:"Primary Lorem ipsum dolor",
  23.         icon: false
  24.     } %}
  25. *IconCache:
  26. IconCache is used by system settings. To avoid using the icon cache regardless of the system settings (e.g. for an icon rendered in an invisible area like <noscript>), set "iconCache" to false:
  27.     {% sw_include '@Storefront/storefront/utilities/alert.html.twig' with {
  28.         type:"primary",
  29.         content:"Primary Lorem ipsum dolor",
  30.         iconCache: false
  31.     } %}
  32. *Message Content:
  33. The component requires the parameters ```content``` or ```list``` to display a message. If no ```type``` is defined it
  34. will use the fallback option (success).
  35.     {% sw_include '@Storefront/storefront/utilities/alert.html.twig' with {
  36.         type:"primary",
  37.         content:"Primary Lorem ipsum dolor"
  38.     } %}
  39. *Message List:
  40. If you need to display a bunch of messages (for example error messages in the registration), you can pass an array
  41. of messages to the template using the parameter ```list```:
  42.      {% set list1 = [
  43.         'Error message 1',
  44.         'Error message 2',
  45.         'Error message 3'
  46.     ] %}
  47.     {% sw_include '@Storefront/storefront/utilities/alert.html.twig' with {
  48.         type:"secondary",
  49.         list: list1
  50.     } %}
  51. *Heading:
  52. To display a heading, use "heading".
  53.     {% sw_include '@Storefront/storefront/utilities/alert.html.twig' with {
  54.         type:"primary",
  55.         content:"Primary Lorem ipsum dolor",
  56.         heading: "Test Heading"
  57.     } %}
  58. *Dismissible Button:
  59. To display a dismissible button set the value of "dismissible" to true.
  60.     {% sw_include '@Storefront/storefront/utilities/alert.html.twig' with {
  61.         type:"primary",
  62.         content:"Primary Lorem ipsum dolor",
  63.         dismissible: true
  64.     } %}
  65. #}
  66. {% block utilities_alert %}
  67.     <div role="alert"
  68.          class="alert {% if type %}alert-{{ type }}{% endif %}{% if dismissible %} alert-dismissible fade show{% endif %}{% if icon != "error" %} alert-has-icon{% endif %}">
  69.         {% block utilities_alert_icon %}
  70.             {% if icon != "false" %}
  71.                 {% set iconCacheSystem = config('core.storefrontSettings.iconCache') %}
  72.                 {% if iconCache === false and iconCacheSystem === true %}
  73.                     {{ sw_icon_cache_disable() }}
  74.                 {% endif %}
  75.                 {% if type == "danger" %}
  76.                     {% sw_icon 'blocked' %}
  77.                 {% elseif type == "warning" %}
  78.                     {% sw_icon 'warning' %}
  79.                 {% elseif type == "info" %}
  80.                     {% sw_icon 'info' %}
  81.                 {% elseif type == "success" %}
  82.                     {% sw_icon 'checkmark-circle' %}
  83.                 {% else %}
  84.                     {% sw_icon 'alert' %}
  85.                 {% endif %}
  86.                 {% if iconCache == false and iconCacheSystem === true %}
  87.                     {{ sw_icon_cache_enable() }}
  88.                 {% endif %}
  89.             {% endif %}
  90.         {% endblock %}
  91.         {% block utilities_alert_content_container %}
  92.             <div class="alert-content-container">
  93.                 {% block utilities_alert_heading %}
  94.                     {% if heading %}
  95.                         <div class="alert-heading h5">
  96.                             {{ heading }}
  97.                         </div>
  98.                     {% endif %}
  99.                 {% endblock %}
  100.                 {% block utilities_alert_content %}
  101.                     <div class="alert-content">
  102.                         {% if list|length > 1 %}
  103.                             <ul class="alert-list">
  104.                                 {% for entry in list %}
  105.                                     <li>{{ entry|sw_sanitize }}</li>
  106.                                 {% endfor %}
  107.                             </ul>
  108.                         {% elseif list|length == 1 %}
  109.                             {% for entry in list %}
  110.                                 {{ entry|sw_sanitize }}
  111.                             {% endfor %}
  112.                         {% else %}
  113.                             {{ content|sw_sanitize }}
  114.                         {% endif %}
  115.                     </div>
  116.                 {% endblock %}
  117.                 {% block utilities_alert_dismissible %}
  118.                     {% if dismissible %}
  119.                         <button type="button"
  120.                                 class="close"
  121.                                 data-bs-dismiss="alert"
  122.                                 aria-label="Close">
  123.                             <span aria-hidden="true">&times;</span>
  124.                         </button>
  125.                     {% endif %}
  126.                 {% endblock %}
  127.             </div>
  128.         {% endblock %}
  129.     </div>
  130. {% endblock %}