Pete Jones Posted May 19, 2016 Posted May 19, 2016 We have a fairly complicated sorting requirement where we are ordering by pages and then by the condition of a checkbox within a repeater, within each page. There are subsequent 2 sorting criteria that are applied. We have split the 3 sort conditions into 3 different selectors which we are then adding to a PageArray. When using $items->add($firstsortedarray) the sorting is ok, when we then add subsequent arrays the ordering of the overall array breaks. Is there a difference in the way ->add works compared to ->append?
LostKobrakai Posted May 19, 2016 Posted May 19, 2016 https://github.com/ryancramerdesign/ProcessWire/blob/master/wire/core/WireArray.php#L716-L726
Pete Jones Posted May 19, 2016 Author Posted May 19, 2016 hmm ok must be something else then. Thanks LostKobrakai. If we wish to specifically control the order of the PageArray (using a key) should we need to add the key in or should the order of the PageArray remain unchanged when we add items?
Craig Posted May 19, 2016 Posted May 19, 2016 In a previous project that needed a specific manual sort, I had some success setting the page field value to a string of IDs in order. $page->items = "1045|1067|1125|1256"; So you could build up a list of IDs in whatever order you want, and then implode() them into the otherPages value when saving the main page.
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