Variable publish_date is a standard field in the āOptionsā tab for pages in Admin.
When creating a item.md, user can enter the āPublishe Dateā field. It will create the following frontmatter in item.md.
I found a way in the configuration > system tab to set the date format - now I found out I do have to re-load each blog article for this to be actively working.
I like the European date format, but the ordering happens apparently like so: day-month-year, so a blog post published on 01-05-2016 would sort higher than a blogpost published on 02-01-2020. At least thatās what it looked like to me.
I donāt think there is a European standard date format. Some use dd-mm-yyyy and others like Germany use dd.mm.yyyyā
The ISO standard is yyyy-mm-dd
I havenāt finalised debugging it, but it seems that if the ordering is using x.publish_date as I suggested, Grav doesnāt know it is a date field. Hence it will order it like a string as you noticed.
When ordering on ādateā the ordering follows the internal value of the date.
@anon76427325 So if I understood you correctly, I would
move the value to the field ādateā instead of the field āpublish dateā
change the ordering back to date on the blog.md
This would revert things back to where they were - the ordering was following the ālast changedā timestamp. Which is not what I intended with my question.
With my question, I intend that a blogpost stays in the right order even if I modify it afterwards.
The date variable allows you to specifically set a date associated with this page. This is often used to indicate when a post was created and can be used for display or sort-order purposes. If not set, this defaults to the last modified time of the page.
If the user explicitly sets the date I expect it to remain the same also after updating the page.
@werdi, I believe the OP of the other post, does not set the date value in Admin manually. In that case, Grav will use the default āmodify dateā as the date for that page. Therefor the ordering changes when editing a page.
Once set manually, it should remain the same despite any changes to the page.
@anon76427325 It makes total sense what you say, but this is not true for my blog. I tried setting up everything you suggested for the three last published blogposts. They donāt appear on top.
Before and after saving the page it is the same date. Also, in either field. The date remains the same but the page jumps on top of the other blogposts.
These are the current settings in blog.md
content:
order:
by: date
dir: desc
The three blogposts with the latest date (see the one in the screenshot, for example) donāt appear on top.
(And Iāve kept the date format year-month-day for now)
Itās possible that at this point the publish_date field is overriding the date field. Meaning, some blog posts I already set to publish date, some blog posts are still on date.
@werdi, I cannot reproduce what you are seeing. And because I cannot see what is happening in you system, it is bit useless for me to continue diggingā¦
At the moment I do not see any role of āpublish_dateā when sorting a collection on ādateā. Only whether ādateā is being set or not.