Skip to content
● Meet Grav Guard: keep every Grav site you run secure and up to date, all from one place. Free for up to 3 sites. Read more →

Display text on a certain day?

Solved by Justin Young View solution

Started by Justin Young 6 years ago · 2 replies · 781 views
6 years ago

Is there a way to display a short text based on the date or even month?

This would be similar to the Fortune plugin, but not random.

6 years ago Solution

Here's a solution

TWIG
{% set message = { "01": 'foo', "02": 'bar' } %} {# each date has a message #}
{% set date = now | date("d") %}
{{ message[date]|default('no data for given day') }}
6 years ago

Nice! Also very useable for weekday messages via changing "d" to "D" and altering the array to elements like
"Mon": 'Go for it! A new week has begun!'

👍 1

Suggested topics

Topic Participants Replies Views Activity
General · by themetman, 23 hours ago
2 40 16 hours ago
General · by Hanns Mattes, 1 week ago
0 121 1 week ago
General · by Karmalakas, 1 week ago
2 185 1 week ago
General · by Hanns Mattes, 3 weeks ago
0 235 3 weeks ago
General · by Dima, 4 weeks ago
1 211 4 weeks ago