Jump to content

Sort by multiple fields in the admin?


evanmcd
 Share

Recommended Posts

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

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

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

  • 2 years later...

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

  • 3 years later...

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

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

×
×
  • Create New...