So I realised when I checked https://irish-diversity-in-tech.netlify.app/events/ - all was not as it seems...
There's no listings for either general tech events and diversity in tech events as it's the end of the month and it's March 1st tomorrow!
Let's "if" this thing
Right, so I only need to wrap the bits in an if statement. Let's see what I can do, maybe check the listings itself and if it's empty, display the message to say there's no listings this month and check the ARCHIVES (which contains past and upcoming events for both general techie events and diversity in tech events).
{% if listings %}
Get events listings code...
{% else %}
Display message that there's no more events this month, etc.
{% endif %}
Added test events for today so I can see the listing appears, and if I remove it, the message should appear.
BUT... that didn't work!
Ok, used the handy dump
to show what gets outputting from listings
and I get []
.
Hmm, ok, so it is empty, maybe we can get the length of the array returned, and if it's zero, then display the message.
{% if listings | length != 0 %}
Get events listings code...
{% else %}
Display message that there's no more events this month, etc.
{% endif %}
And hey presto, that worked! π
Added that check for diversity in tech events section as well, and tried adding test data and removing it to see the message or listing appears correctly.
So quick fix all committed back
Top comments (0)