Skip to content
Grav 2.0 is officially stable. Read the announcement →

Community guidelines

Please keep discussions civil and on-topic. Repeated violations may lead to a temporary ban.

Support

Future Events Not Showing After a Certain Date in Grav CMS

Started by saeed 2 years ago · 4 replies · 78 views
2 years ago

I'm experiencing an issue with my Grav CMS site where future events beyond a certain date are not displaying. Here are the details:
Events with future dates beyond a certain point (e.g., beyond for from 15.08.2024 ( Today is 18.07.2024) are not showing up on the site. This issue persists despite setting showFutureEvents: true in the configuration.
In my flex-catalog.en.md file, I have the following settings:,
options:
showFutureEvents: true
showCurrentEvents: true
showPastEvents: true
sortBy: date
sortDirection: desc
cards_per_row: 3
show_post_titles: true
show_post_date: true
show_post_category: true
group_by_category: true

I'm looking for guidance on resolving this issue so that all future events display correctly, regardless of their date. Any insights or suggestions on what might be causing this limitation and how to fix it would be greatly appreciated.

Screenshot 2024-07-18 125045|690x294

I debug the Data, it doesn't fetch any Data for that Time to filter out
and This is the related twig file:

{% import "_macros/typography.twig" as typoMacros %}

{% if not theme_config['production-mode'] %}
{% do block.disableCache() %}
{% endif %}

{% set contentParts = object.content|split('===') %}
{% set content = {
summary: contentParts[0],
readmore: contentParts[1] ?? null,
all: contentParts|join
} %}

{% set imageMode = 'resize' %}

{% set date_format = 'd.m.Y' %}
{% set startdate_format = object.end_date ? 'd.m. ' : date_format %}
{% set time_format = 'H:i' %}

{% set startdate = object.start_date %}
{% set enddate = object.end_date ?: null %}
{% set currentdate = 'now'|date('Y-m-d') %}

{% set referencedate = enddate ?: startdate %}
{% set pastEvent = referencedate ? referencedate < currentdate %}

<article class="{{ CssClasses('event', articleClasses, pastEvent ? 'past') }}">
{% set image = getPageImage(object.media, object.image, header.use_placeholder_image) %}
{% set imageTitle = image.meta.title %}
{% set imageAlt = image.meta.alt %}
{% set imageClasses = 'mb-5 img-fluid lazyload' %}

TWIG
{% set options = {
    pageContent: (content is not empty),
    pageContentClasses: 'event-info',
    moduleContent: (image),
    moduleClasses: 'article-image',
    modulePosition: header.options.image_align ?? 'right',
    moduleWidth: header.options.image_width|default('6'),
    moduleTitleTag: 'h3',
    moduleTitleClass: 'article-heading',
    hideModuleTitle: true,
    gridStyle: header.options.image_align in ['top', 'bottom'] ? 'vertical' : 'horizontal',
    debug: false
} %}
{{ options.debug ? dump(options) }}

{# Prepare content #}
{% set showTitle = true and header.options.showEventTitles|default(true) %}
{% set showDate = true %}
{% set showCategory = true and object.category and object.category != 'Keine' %}

{% set pageContent %}
    {% if showCategories %}
        <h5 class="category">{{ object.category }}</h5>
    {% endif %}

    {% if showDate %}
        <div class="date fw-bold" data-timestamp="{{ startdate|date('U') }}">
            <span class="start-date">{{ startdate|date(startdate_format) }}</span>
            {% if enddate %} - <span class="end-date">{{ enddate|date(date_format) }}</span>{% endif %}
        </div>
    {% endif %}
            {% if showDate %}
        <div class="date fw-bold" data-timestamp="{{ startdate|date('U') }}">
            <span class="start-date">{{ startdate|date(startdate_format) }}</span>
            {% if enddate %} - <span class="end-date">{{ enddate|date(date_format) }}</span>{% endif %}
        </div>
    {% endif %}

    {% if showTitle %}
        <div class="title fw-bold">{{ object.title }}</div>
    {% endif %}

    {% if object.subtitle %}
        <div class="subtitle speaker">{{ 'EVENTS.LABELS.SUBTITLE'|t }}: {{ object.subtitle }}</div>
    {% endif %}

    {% if object.location %}
        <div class="location">{{ 'EVENTS.LABELS.LOCATION'|t }}: {{ object.location }}</div>
    {% endif %}

    {% if object.start_time or object.end_time %}
        <div class="time">{{ 'EVENTS.LABELS.TIME'|t }}: {{ object.start_time }}{% if object.end_time %} - {{ object.end_time }}{% endif %}</div>
    {% endif %}

    {% if content.summary or content.readmore %}
        <div class="description mt-3">
            {{ typoMacros.processContent(content.all) }}
        </div>
    {% endif %}
{% endset %}

{% set moduleContent %}
    {% if image %}
        {% if imageMode == 'zoom' %}
            {% set aspectRatio = 4/3 %}
            {% set imageWidth = options.gridStyle == 'vertical' ? 1280 : 1280 * options.moduleWidth / 12 %}
            {{ image.cropZoom(imageWidth, imageWidth/aspectRatio).html(imageTitle,imageAlt,imageClasses)|raw }}
        {% else %}
            {{ image.cropResize(600, 600).html(imageTitle, imageAlt, imageClasses)|raw }}
        {% endif %}
    {% endif %}
{% endset %}

    <script>
    console.log({
        current_date: {{ currentdate|json_encode|raw }},
        start_date: {{ startdate|json_encode|raw }},
        end_date: {{ enddate|json_encode|raw }},
        past_event: {{ pastEvent|json_encode|raw }},
        future_event: {{ futureEvent|json_encode|raw }},
        show_past_events: {{ header.options.showPastEvents|json_encode|raw }},
        show_current_events: {{ header.options.showCurrentEvents|json_encode|raw }},
        show_future_events: {{ header.options.showFutureEvents|json_encode|raw }},
        referencedate: {{ referencedate|json_encode|raw }},
        object: {{ object|json_encode|raw }}
    });
</script>

{# Embed content #}
{% block embedded_content %}

    {% embed 'embeds/content-grid.html.twig' with {title: object.title} %}

        {% block page_content %} {{ pageContent }} {% endblock %}
        {% block module_content %} {{ moduleContent }} {% endblock %}

    {% endembed %}

{% endblock %}

</article>

Thank you for your help!

2 years ago

AFAIK Grav doesn't have event functionality by default. Check your plugins

2 years ago

i meant like a new post! but in this section each post hast a start_date, that shows the upcoming or pas events!

2 years ago

@saeed:
showFutureEvents: true
showCurrentEvents: true
showPastEvents: true

These are not Grav options for any lists. Most likely some plugin, but you never linked to it


@saeed:
each post hast a start_date, that shows the upcoming or pas events

This statement doesn't even make sense. How can start date show events?

Suggested topics

Topic Participants Replies Views Activity
Support · by Thomas, 1 week ago
2 55 13 hours ago
Support · by Anna, 3 days ago
2 60 15 hours ago
Support · by Justin Young, 16 hours ago
1 31 16 hours ago
Support · by Duc , 1 week ago
2 65 5 days ago
Support · by Colin Hume, 1 week ago
2 58 5 days ago