evanmcd Posted June 28, 2012 Share Posted June 28, 2012 Hi, I wonder if there is any way to set a template to sort it's children by more than one column. I love that we can set this at either the template or page level, but I'd like to be able to sort by two columns as in SQL 'sort by column1, column2' If there's not a solution, I'll consider doing a module for it. Thanks. Link to comment Share on other sites More sharing options...
slkwrm Posted June 29, 2012 Share Posted June 29, 2012 As far as I know this option isn't available in the back-end, but I remember Ryan wrote somewhere on this forum about the usage of more then one field to sort by in code. It should be something like this: $pages->find("parent=$page, sort=field1, sort=field2"); Link to comment Share on other sites More sharing options...
apeisa Posted June 29, 2012 Share Posted June 29, 2012 Yep, the API supports sorting with multiple values, but the admin UI doesn't (at least yet). Link to comment Share on other sites More sharing options...
ryan Posted June 29, 2012 Share Posted June 29, 2012 This is correct. The admin UI doesn't let you select multiple fields to sort by yet. But your API calls can sort by as many fields a you want. It will use them in the order you specify them in the selector. Link to comment Share on other sites More sharing options...
evanmcd Posted July 3, 2012 Author Share Posted July 3, 2012 Thanks all. I may need to hack a quick plugin together. I'll post back here if I do. Link to comment Share on other sites More sharing options...
blackeye1987 Posted October 22, 2014 Share Posted October 22, 2014 i made a workaround (pretty dirty) for the same topic. i set a value i want to sort by. 0 config 1 preview 2 statistic 3 formular 4 (here was my problem) i have 6 tabs. so i gave the tabs a value 1 - 6 and added that value to my sort mechanic. i have a litle hook after save to set the position again. $page->setOutputFormatting(false); $page->ssort = 4 + $page->tab_position; $page->save(); Link to comment Share on other sites More sharing options...
a-ok Posted April 11, 2018 Share Posted April 11, 2018 Sorry to bring this back up but is this possible with a hook for the admin page tree? I want to sort my pages in the admin, for a specific parent/child set up, by date then by status (so unpublished pages are at the top). Any thoughts? Link to comment Share on other sites More sharing options...
LostKobrakai Posted April 11, 2018 Share Posted April 11, 2018 http://modules.processwire.com/modules/process-page-list-multiple-sorting/ Link to comment Share on other sites More sharing options...
a-ok Posted April 11, 2018 Share Posted April 11, 2018 12 minutes ago, LostKobrakai said: http://modules.processwire.com/modules/process-page-list-multiple-sorting/ Thanks but is there a way to do this via a hook myself? Link to comment Share on other sites More sharing options...
LostKobrakai Posted April 11, 2018 Share Posted April 11, 2018 Just look at the modules code. It's just a few handful of code and a single hook. 2 Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now