Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sorting options #34

Open
FairbanksMike opened this issue Dec 28, 2022 · 4 comments
Open

Sorting options #34

FairbanksMike opened this issue Dec 28, 2022 · 4 comments
Labels
documentation Improvements or additions to documentation

Comments

@FairbanksMike
Copy link

I see in the description that galleries and images can be sorted by date or name, but what are the other options to put in the setup.php file to get the different sorts?

"sortAlbums": "newest",
"sortImages": "newest",

@FairbanksMike
Copy link
Author

I believe I found the answer in another post...

"newest"
"oldest"
"alphabetical"

Is this all of them?

@david-novafacile
Copy link
Contributor

Yes, currently thats all.

In v2 it will be dateASC, dateDESC, nameASC, nameDESC and random. v2 is in internal alpha testing and gets public in next few months including a better documentation.

@david-novafacile david-novafacile added the documentation Improvements or additions to documentation label May 13, 2023
@tehsideshow
Copy link

I was just looking for the sorting options, glad I found this. Thanks for the work, the gallery is great.

@keusendev
Copy link

Don't know if of interest, I added the "nameDESC" by adding in nova-base/lib/novaGallery.php:

  // Sort alphabetically descending
  protected function orderByNameDsc($list)
  {
    $ascOrder = $this->orderByName($list);
    $dscOrder = array();

    foreach (array_reverse($ascOrder, true) as $key => $value) {
      $dscOrder[$key] = ($ascOrder[$key] = $value);
    }

    return $dscOrder;
  }

and expanding the protected function order($list, $order) with:

  protected function order($list, $order)
  {
    switch ($order) {
      case 'defaultDSC':
        // order alphabetically descending
        $list = $this->orderByNameDsc($list);
        break;
    }
    return $list;
  }

After that, one can add

"sortAlbums": "defaultDSC"

in the nova-config/site.php config.

I know, it is a little hacky, but I works. Looking forward to see v2 of the novaGallery 😄.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation
Projects
None yet
Development

No branches or pull requests

4 participants