novafacile / novagallery

novaGallery - a beautiful and and ease to use php image gallery for your photos - flat file - no database required - modern responsive design
https://novagallery.org
GNU Affero General Public License v3.0
74 stars 11 forks source link

Sorting options #34

Open FairbanksMike opened 1 year ago

FairbanksMike commented 1 year ago

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 commented 1 year ago

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

"newest" "oldest" "alphabetical"

Is this all of them?

david-novafacile commented 1 year ago

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.

tehsideshow commented 1 year ago

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

keusendev commented 8 months ago

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