Skip to content
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

Custom header collection sorting doesn't support date format #1261

Closed
ichik opened this issue Jan 19, 2017 · 3 comments
Closed

Custom header collection sorting doesn't support date format #1261

ichik opened this issue Jan 19, 2017 · 3 comments

Comments

@ichik
Copy link

ichik commented Jan 19, 2017

Hi,
I'm trying to establish custom sorting of collection of pages in a timetable like this:

order:
    by: header.eventdate
    dir: asc

Unfortunately it doesn't seem to support datetime format that is stored in this custom header (i.e. eventdate: '03-02-2017 22:18').

As a result event from February 3rd comes before January 20th for example. I can resort to using just date for sorting, but date of creation an item is not an event date per se.

@rhukster
Copy link
Member

rhukster commented Jan 20, 2017

I've looked at this and really we have no way to really know what or how to order custom header type sort fields. For this reason, I suggest you change the header.eventdate to use ISO format dates: yyyy-mm-dd. This way the sort order will be correct with regular natural sort order that is assumed for all such fields.

You can then reformat this on display via the Twig Date filter: http://twig.sensiolabs.org/doc/2.x/filters/date.html

@ichik
Copy link
Author

ichik commented Jan 20, 2017

The thing is, though, that the format in the field is defined by this blueprint:

header.eventdate:
                      type: datetime
                      label: Event date

And the actual data is then set through Admin plugin, is there any way to change the format Admin plugin uses?

w00fz added a commit to getgrav/grav-plugin-admin that referenced this issue Jan 20, 2017
@w00fz
Copy link
Member

w00fz commented Jan 20, 2017

This is now fixed. The fix involves a new option for the datetime field that allows you to specify manually the format. So in your case you could write in the blueprint:

header.eventdate:
  type: datetime
  label: Event date
  format: 'Y-m-d'

which will force the format to 2017-01-20 for that particular field.

rhukster pushed a commit that referenced this issue Nov 28, 2017
…inified (#1261) (#1763)

* Fixed CSS Pipeline failing with Google remote fonts if the file was minified (#1261)

* Assets: Make tag check ungreedy again -- inline js may have tags in the content
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants