We use a blog to present and list our company events. I would like the listing to be sorted according to the date of the event. The date is saved in a custom module text field.
Is it possible to access the text field from the sort function in the foor loop?
Like this: {% for content in contents|sort(False, False, widgets.event_date.body.value) %}
I am not sure if others on the community might have other thoughts but I don't believe you can sort blog listings by a custom module text field. The markup loops through "contents" which are the posts:
{% for content in contents %}
<div class="post-item">
Post item markup that renders with each iteration.
</div>
{% endfor %}
Perhaps you could do something such as set topics with the date ('Event Date 2018-09-21', 'Event Date 2018-10-22') and then filter by topics with "Event Date" and sort alphabetically?
{% for content in contents %}
{% for topic in content.topic_list %}
{% if "Event Date" in topic.name %}
{% topic.name|sort(False, False, 'name') %}
{# Add your post markup here #}
{% endif %}
{% endfor %}
{% endfor %}
I am not sure if others on the community might have other thoughts but I don't believe you can sort blog listings by a custom module text field. The markup loops through "contents" which are the posts:
{% for content in contents %}
<div class="post-item">
Post item markup that renders with each iteration.
</div>
{% endfor %}
Perhaps you could do something such as set topics with the date ('Event Date 2018-09-21', 'Event Date 2018-10-22') and then filter by topics with "Event Date" and sort alphabetically?
{% for content in contents %}
{% for topic in content.topic_list %}
{% if "Event Date" in topic.name %}
{% topic.name|sort(False, False, 'name') %}
{# Add your post markup here #}
{% endif %}
{% endfor %}
{% endfor %}
This HubDB solution is very helpful. It feels a bit unnecessary to have to add the events in more than one place, but seems like a pretty quick and straight forward solution.