1

Edit: This is confirmed as a bug in Craft, that will be fixed in its next release. If you're running into this, please see the temporary fix over at GitHub: https://github.com/craftcms/cms/issues/3772

I'm leaving up the original post for posterity.

--

I'm running into an issue with the recent update for Craft 3.1. I've not changed any of my code on the archive pages, but the list of entries on my archive pages stopped showing up.

Here is the code I use to set up the date ordering.

{% set firstEntryEver = craft.entries.section('posts').orderBy('postDate asc').one() %}
{% set lastEntryEver = craft.entries.section('posts').orderBy('postDate desc').one() %}
{% if craft.app.request.getSegment(2) is null %}
    {% set year = 2018 %}
{% else %}
    {% set year = craft.app.request.getSegment(2) %}
{% endif %}
{% set archiveBlurbs = craft.entries.section('archives').type('yearBlurb').archiveYear(year) %}
{% set monthBlurbs = craft.entries.section('archives').type('monthBlurb').archiveYear(year) %}
{% set entriesInYear = craft.entries.section('posts').limit(null).after(year).before(year+1).all() %}

And the call I use is {% for month, entriesInMonth in entriesInYear | group("postDate|date('F')") %}. The content is then separated by month over a single year.

The logic I use here generally follows the official docs with some light modifications. I find that the content for all years shows up if I remove the before.

Any idea what might be at play here?

1

It seems that before and after() don't work with the year as an int, if instead of '2018', you use '2018-01-01', your code works again. Check this.

Basically, use a DateTime object :)

  • Actually, this doesn't seem right. Using '2018' use to work... – Oli Feb 1 at 18:14
  • I'll give this a try, but I should point out that this worked all the way up until my most recent Craft update. – Ernie Smith Feb 1 at 18:23
  • Yes, hence my comment above... might be a little bug :) – Oli Feb 1 at 18:24
  • 1
    I'll give this thread a shout over at Github. – Ernie Smith Feb 1 at 18:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.