Suppose you want to display a list of directors that are still active, depending on a certain date. In the past, we would’ve created some logic looking at the begin- and end dates of the mandat of each director:
{% comment %}the date of the legal report is what we need to list the active directors{% endcomment %}
{% assign date_gm = period.custom.av.datum | date:"%Y/%m/%d" %}
{% comment %}show the active directors{% endcomment %}
{% for person in period.directors %}
{% comment %}check which persons have valid mandats{% endcomment %}
{% assign show_begin_mandat = false %}
{% assign show_end_mandat = false %}
{% assign begin_mandat = person.director_start_date | date:"%Y/%m/%d" %}
{% assign end_mandat = person.director_end_date | date:"%Y/%m/%d" %}
{% if date_gm >= begin_mandat or begin_mandat == blank %}
{% assign show_begin_mandat = true %}
{% endif %}
{% if date_gm <= end_mandat or end_mandat == blank %}
{% assign show_end_mandat = true %}
{% endif %}
{% comment %}show active mandats{% endcomment %}
{% if show_begin_mandat and show_end_mandat %}
**{{ person.name }}**
{% endif %}
{% endfor %}
Another case that has this logic, is seen here.
However, that’s a lot of extra coding that always needs to be done everywhere you want to show the active directors.
From now on however, we added an extra filter active_as_director_on to the people drop period.directors
:
{% assign active_directors = period.directors | active_as_director_on:date_gm %}
{% for person in active_directors %}
{{ person.name }}
{% endfor %}
In the filter you can have any date, on which the drop will automatically be filtered upon (looking in the background to the info from the database variables director_start_date & director_end_date.
Another filter we have, but good to mention, is the active_as_director
method, which automatically will filter the directors based upon the begin and end date of the bookyear your period resides in:
{% assign directors_by = period.directors.active_as_director %}
{% for person in directors_by %}
{{ person.name }}
{% endfor %}
That’s another case saving some coding lines