Sort subpages by published date in pages section

In the pages section, I would like Public subpages to be sorted by their ‘published’ date: the date when they were added to the Public list.

How to ?

/edit> Alternatively I’d like to sort by page creation date/time… so last one created goes on top… (or alternatively on bottom, but better if on top)

Thank you

Do you store the date when a page is created/published?

The only date related thing I am doing is having this setting on each subpage blueprint:
num: ‘{{ page.created.toDate(“YmdHi”) }}’

What is created, a custom field?

Then you can use the sortBy property to sort by this field?

Sorry, I don’t understand the question.

I have a panel page, call it ‘Master’, with two pages sections: Draft and Public, both are sortable: false.

  - width: 1/2
        type: pages
        headline: Draft
        text: "{{ page.intendedTemplate }} | {{ page.title }}"
        status: draft
        sortable: false
          - announcement
          - event
          - call
          - article
  - width: 1/2
        type: pages
        headline: Public
        text: "{{ page.intendedTemplate }} | {{ page.title }}"
        status: listed
        sortable: false

All the templates that can be used to add subpages to Draft section, have this line in their corresponding blueprints:

num: ‘{{ page.created.toDate(“YmdHi”) }}’

…which as far as I understand sets the numbering of those pages folders on the content folder.

But, as far as I understand that numbering is not a field that can be used in the sortBy option of the ‘Public’ pages section of the ‘Master’ page blueprint, is it?


I don’t know what created is supposed to be. There is no such native method/page property I’m aware of, so if that’s not a field you use in your template, I wonder what it does.

If it was a field or a property, you can use it to sort by.

Oh, but, I am just copying the chronological sorting section of the page blueprint reference, which says:


The num option defines which numbering scheme to use when a page is published.


Chronological sorting

By date

num: '{{ page.created.toDate("Ymd") }}'

By datetime

num: '{{ page.created.toDate("YmdHi") }}'

That’s just an example. It only makes sense if you use a field called created. The only date related native method is modified, everything else you have to put into your blueprints and fill with content.

You can use a date field created and set the default to today to add a date whenever a page is created, or you can use a field called publish that you fill using a hook when the page is published.

Oh I see… makes sense.

I’d say that is not clear at all from the reference. ‘Chronological Sorting’ is not a sub-section of ’ Sorting by query result’. Both are h3 headings. So it is not clear that the created-toDate is an example of querying by custom field. Neither it says “as an example” or similar. I guess you’ll tell me to fill an issue at github.

In any case, as far as I understand, you are telling me that I should ‘manually’ store the creation or publication date/time in a field, so I can use it to sort via SortBy.

How to ?
Perhaps I’ll have a hidden date-time field in the blueprint.
Then a page.changeStatus:after hook, where I’d try to listen for “listed” or “published” status
And when that happens, fill the hidden date-time field with the actual time.

Does that sound reasonable, would there be a less hacky way of doing this?

Thank you.

Exactly like that. I don’t think it’s hacky, how else could that possibly work?

Maybe we have to rename the first of those three, they are of course all queries, only the first one is a type of query that doesn’t return a date but an integer.

And done:

I would perhaps expect to be able to natively sort subpages by creation date-time.

Because what happens if you use sortable: false, and not provide a sorting option?


Where would you get that information from? Most Unix systems don’t track file creation times. and in any case, that information would not be reliable if files are moved around.

Then pages use the default sorting by number when publishing them.

And when is a number given to a page/folder? on creation? or when it becomes listed?

I can’t for the life of me find this information on the reference, and I know it is there, I’ve read it! but can’t find it.

thank you

Any number, no matter if it is a date or the standard sorting number or the zero for alphabetical sorting is prepended only when a page’s status is changed to listed. That’s the same as in Kirby 2.

In a pages section, pages can only be manually sorted if the numbering scheme is set to the default numbering. Pages with chronological or alphabetical sorting cannot be manually sorted, anyway.


Right now, if I set sorting: false without providing a sorting method, sorting is set to default, which as you already explained means sorting by number… 1,2,3 etc.

Nevertheless when the user publishes, s/he has to sort the page by number using the sorting dropdown menu. Isn’t it a bit contradictory that while sorting is set to false, the user still has to sort manually when publishing ?

If sorting is set to false, shouldn’t pages be sorted automatically by publishing order? With this I mean that each new published page gets index++ so to say, as sorting number.

Sorry for insisting on the matter, I am just trying to fully get it.
Thank you very much for your help.

I don’t really have an answer. Theoretically yes, but the sortable option only applies to drag&drop sorting within the current pages section, not to preventing sorting in general. Also, you could even have contradictory settings if you use the same set of pages in two different pages sections. I don’t know if this makes sense and what a good solution would be like.

1 Like

I opened an idea/issue.
Thanks again