Jump to content

Using $page->add($items) ordering


Pete Jones
 Share

Recommended Posts

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?

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...