-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ordering by date in custom field #1368
Comments
@vitopepito Thanks for creating this. I'll look at it today. Ref: #274 |
@vitopepito I think your workaround may not be doing what you think. The Now, there is a problem with using custom dates in the header as your sort field. The sorter does not know the type of value the custom field is (aside from array fields, which are imploded), so it falls back to treating the field as a string for sorting. So the real issue here is how we can determine if the field in the |
My current thought is to make a new Utils method to regex check a string and see if it is in one of the allowed date formats from \Grav\Common\Utils::dateFormats. Any objections? |
You are probably right about my workaround. Of course it would be nice if custom fields are recognised as dates. Another option would be to just use a date format of type |
Closing to due to inactivity |
Hi, I have the same problem as the original author. I would like to sort collection by date in header.event.start using format dd-mm-yyyy. Is it possible now, a year later? |
I experienced the following issue: In a page collection with a header like in the code below, the items will not be ordered chronologically if the field 'header.event.start' is in date format.
This is an example of an item
I think that the date format in the custom field is not recognized and ordering by number is used. Using the american date format makes the items ordered by month first, but it is not properly recognized as a date.
Work around
The collection header can use a dateRange in combination with order to achieve chronological ordering that can be either descending or ascending.
This works for me but is kind of hacky. The documentation of dateRange should be updated to show the ordering options.
The text was updated successfully, but these errors were encountered: