Jump to content
evanmcd

Sort by multiple fields in the admin?

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.

Share this post


Link to post
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");

Share this post


Link to post
Share on other sites

Yep, the API supports sorting with multiple values, but the admin UI doesn't (at least yet).

Share this post


Link to post
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.

Share this post


Link to post
Share on other sites

Thanks all. I may need to hack a quick plugin together. I'll post back here if I do.

Share this post


Link to post
Share on other sites

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();

Share this post


Link to post
Share on other sites

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?

Share this post


Link to post
Share on other sites

Just look at the modules code. It's just a few handful of code and a single hook.

  • Like 2

Share this post


Link to post
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

  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By humanafterall
      Hi,
      I would like to set an admin template to 'https only' as recommended in the Processwire security docs.
      However if I do this it forces this setting locally too, resulting in https://localhost requests which result in an error page.
      Is there a simple way round this? Setting https for templates in the config?
      Thanks!
    • By jom
      Chäs & Co is a b2b cheese trader. They love good cheese and are proud of their excellent knowledge und connections to small cheese producers. They maintain a custom made database and used to copy/paste (!) the cheese infos to the former CMS (Contao). Since substituting the database with ProcessWire was no option, they export now the database to a csv file and import it to the new website (expanded version of module ImportPagesCSV).
      From there, the pw magic begins. The staff works with the admin interface: They search and find products in notime using the build-in search field (using cheese names or id. Using ids only possible by adding hook, see this forum thread). They generate price lists easily based on a template, providing checkboxes and option buttons for some restrictions, choose i.e. the cheese origin and price audience (all implemented as page selectors). By saving the page a PDF list gets generated (using mpdf, a php pdf library).
      The visitors can sort and filter the products using a form by shuffle.js. Product details are shown in a popup (fancybox). There's also the option for generating a nice pdf data sheet. No CSS framework being used.
      Other modules used: ProcessJumpLinks, ProcessProMailer, ProcessWireUpgrade.
      Visual design: Nicole Haller


    • By DanielKit
      Hi. I'm currently stuck at the login page in my project. Once I enter my admin username and my password and press login, nothing happens. The page just reloads. However, the URL changes from http://myipaddress/processwire to http://myipaddress/processwire/?login=1. I've checked all of my server settings, and to my knowledge, all seems to be fine there. I don't know where to go from here.. Thanks in advance!
    • By modifiedcontent
      Small annoyance: I get a horizontal scrollbar in UIkit admin area - or actually Admin Theme Boss based on Uikit 3. I tried to fix it with CSS, but had trouble isolating/targeting it and don't want to mess with module or core files. I think this issue has been reported before. Is there a recommended fix? 
    • By codevark
      The Minimal Site works fine, but if I try to login as admin, I have no idea what the credentials are.
      I did not do the "install" process myself. The OVA came with everything set up, but there's no mention of the PW admin credentials being set to some initial value.
      Wondering if anyone else has tried the Bitnami OVA and if there's a simple answer.
      --Pete
×
×
  • Create New...