Skip to content

Commit

Permalink
Add example for Snowboard flash usage, fix links on Flash page, add meta
Browse files Browse the repository at this point in the history
  • Loading branch information
bennothommo committed Oct 21, 2024
1 parent b650176 commit bdc7738
Showing 1 changed file with 20 additions and 2 deletions.
22 changes: 20 additions & 2 deletions markup/tags/flash.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
---
title: "The 'flash' markup tag"
description: "Render flash messages stored in the user session within your theme."
---
# {% flash %}

The `{% flash %}` and `{% endflash %}` tags will render any flash messages stored in the user session, set by the `Flash` PHP class. The `message` variable inside will contain the flash message text and the markup inside will repeat for multiple flash messages.
Expand All @@ -10,7 +14,7 @@ The `{% flash %}` and `{% endflash %}` tags will render any flash messages store
</ul>
```

You can use the `type` variable that represents the flash message type &mdash; `success`, `error`, `info` or `warning`.
You can use the `type` variable that represents the flash message type - `success`, `error`, `info` or `warning`.

```twig
{% flash %}
Expand All @@ -28,9 +32,23 @@ You can also specify the `type` to filter flash messages of a given type. The n
{% endflash %}
```

If you are using the [Snowboard Flash utility](../../snowboard/extras#flash-messages) in your theme, you should use the following code to ensure that flash messages are handled correctly by this utility:

```twig
{% flash %}
<p
data-control="flash-message"
class="flash-message fade"
data-flash-type="{{ type }}"
data-flash-duration="5">
{{ message }}
</p>
{% endflash %}
```

## Setting flash messages

Flash messages can be set by [Components](../../docs/cms/components) or inside the page or layout [PHP section](../../docs/cms/themes#php-code-section) with the `Flash` class.
Flash messages can be set by [Components](../../cms/components) or inside the page or layout [PHP section](../../cms/themes#php-code-section) with the `Flash` class.

```php
<?php
Expand Down

0 comments on commit bdc7738

Please sign in to comment.