dps123 Posted May 10, 2016 Share Posted May 10, 2016 I'm trying to sort a $pages->find result by a checkbox value. sort=my_repeater.my_checkbox The idea is that I get pages with the checkbox unticked before pages with the checkbox ticked, i.e. 0 to 1. Because I haven't given my checkbox fields a name, they are using the field name. I can see in PW that the checkboxes are labelledmy_checkbox_repeater123456 So I think my sort is not working. Is there a way around this? Link to comment Share on other sites More sharing options...
LostKobrakai Posted May 10, 2016 Share Posted May 10, 2016 The id at the end of the field name is only used in the admin backend to have unique field names for each repeater otherwise they would overwrite each other on save. Link to comment Share on other sites More sharing options...
dps123 Posted May 10, 2016 Author Share Posted May 10, 2016 Oh, I see. So my sort should be working. Let me take a look and possibly post another question! Link to comment Share on other sites More sharing options...
dps123 Posted May 10, 2016 Author Share Posted May 10, 2016 I can see there is an issue when I'm trying to sort pages by the repeater value. So when I'm doing sort=my_repeater.my_checkbox and wanting an order of 0 to 1, if there are no repeater items on a page, they are appearing first in my list. Can I do something for that? Link to comment Share on other sites More sharing options...
dps123 Posted May 11, 2016 Author Share Posted May 11, 2016 Anyone? Link to comment Share on other sites More sharing options...
Robin S Posted May 11, 2016 Share Posted May 11, 2016 Does reversing the sort order help? sort=-my_repeater.my_checkbox Link to comment Share on other sites More sharing options...
dps123 Posted May 11, 2016 Author Share Posted May 11, 2016 Unfortunately not; that will give me checked items first. I'm just looking at this: https://processwire.com/talk/topic/3571-sorting-page-array-containing-pages-without-the-sort-field/, as that might be more like what I need. 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