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

Ordering by date not working [bug]

Started by Alexander Kim 8 years ago · 0 replies · 426 views
8 years ago
TWIG
{% set options = { items: '@root.descendants', 'order': {'by': 'date', 'dir': 'asc'}, 'pagination': false } %}
{% set main_collection = page.collection(options) %}

{% for p in main_collection %}
    {% set image = p.media[p.header.image].cropZoom(540, 310) %}

    <article class="main-news">
        <a href="{{ p.url }}" class="d-block mb-3">
            <img src="{{ image.url }}" alt="{{ p.title }}" class="img-responsive w-100 rounded">
        </a>

        <a href="{{ p.url }}">
            <h4>{{ p.title }}</h4>
        </a>
    </article>
{% endfor %}

Item 1 has date: 03/04/2018 10:00
Item 2 has date: 03/04/2018 11:00

Item 2 is shown first, that's right, but if i change date in Item 1 to 12:00, it won't be first. Is it bug?

Suggested topics

Topic Participants Replies Views Activity
Support · by Thomas, 1 week ago
2 60 15 hours ago
Support · by Anna, 3 days ago
2 66 18 hours ago
Support · by Justin Young, 19 hours ago
1 33 18 hours ago
Support · by Duc , 1 week ago
2 69 5 days ago
Support · by Colin Hume, 1 week ago
2 61 6 days ago