rasteiner / k3-pagesdisplay-section

K3 plugin: display any page list in a section. Any parent, many parents, filtered, don't care.
Other
45 stars 8 forks source link

sortBy query #24

Closed jaro-io closed 1 year ago

jaro-io commented 1 year ago

hey @rasteiner ✨ i would love to be able to sort the pages in my pagesdisplay sections. and pls don’t get me wrong. i don’t mean manual sorting in the panel, like you can do with the regular pages section and listed pages. i just mean using sortBy() inside the query. like you can use filterBy().

i tried both of these options but none seemed to work:

section:
    type: pagesdisplay
    sortBy: date desc
    query: page.children

section:
    type: pagesdisplay
    query: page.children.sortBy('date', 'desc')

would be loooovely if you could add this! thank you so much. 😍

rasteiner commented 1 year ago

Hello 👋

both methods should work and were definitely functioning in the past. Will have a look at this tomorrow. What Kirby version are you using?

jaro-io commented 1 year ago

kirby 3.9, pagesdisplay 0.2.4

but i am pretty sure i also had that problem before upgrading to 3.9..

thank you so much 🙏🏻✨🐋

rasteiner commented 1 year ago

I'm unable to reproduce the problem with those versions 🤷 and both options correctly work here. Just for testing, does putting this into a template produce the expected output for you?

<?php foreach($page->children()->sortBy('date', 'desc'): ?>
  <?= $page->title() ?>: <?= $page->date() ?>
<?php endforeach ?>

What is stored in the date field?

jaro-io commented 1 year ago

@rasteiner i am so sorry, haha. i have wasted your time. i was extending a pages section blueprint. and just overrode the type to pagesdisplay. but i didn’t see that in the base version i already had some sorting options set. if i remove those it of course works all fine again. sorryyy, maybe it was just too late yesterday. anyway, thank you for your time and looking into this so quickly! i really appreciate that.

🍁 🍂