novagallery icon indicating copy to clipboard operation
novagallery copied to clipboard

Sorting options

Open FairbanksMike opened this issue 2 years ago • 4 comments

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 avatar Dec 28 '22 02:12 FairbanksMike

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

"newest" "oldest" "alphabetical"

Is this all of them?

FairbanksMike avatar Dec 29 '22 18:12 FairbanksMike

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 avatar Jan 12 '23 09:01 david-novafacile

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

tehsideshow avatar Aug 31 '23 04:08 tehsideshow

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 😄.

keusendev avatar Jan 03 '24 21:01 keusendev