samtiria / nextgen-gallery

Automatically exported from code.google.com/p/nextgen-gallery
0 stars 0 forks source link

Tag Galleries Don't Honor Sort Direction Option #397

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. Create a tag gallery:

[nggtags gallery="someTag"]

2. Change the sort order in Gallery > Options > Gallery

3. Note that the sort order is always Ascending regardless of the setting you 
choose

What is the expected output? What do you see instead?

When you change the Ascending vs Descending radio button, the tag gallery 
should display with the chosen sort order

What version of the product are you using? On what operating system?

NGG: 1.8.2
WP: 3.2.1

Please provide any additional information below.

The problem is that the nggShowGalleryTags function never sources the 
configured nggGallery options and never looks at (or modifies) the sort order 
before calling nggCreateGallery(). 

The following additions to the nggShowGalleryTags function clear this up:

=====
>diff -u nggfunctions.php nggfunctions.php.new 
--- nggfunctions.php    2011-07-12 08:52:36.000000000 -1000
+++ nggfunctions.php.new        2011-07-29 10:53:16.000000000 -1000
@@ -848,6 +848,8 @@
  */
 function nggShowGalleryTags($taglist) { 

+    $ngg_options = nggGallery::get_option('ngg_options');
+
     // $_GET from wp_query
     $pid    = get_query_var('pid');
     $pageid = get_query_var('pageid');
@@ -855,6 +857,10 @@
     // get now the related images
     $picturelist = nggTags::find_images_for_tags($taglist , 'ASC');

+    // reverse $picturelist if sorting descending
+    if ( $ngg_options['galSortDir'] == 'DESC' )
+        $picturelist = array_reverse($picturelist);
+
     // look for ImageBrowser if we have a $_GET('pid')
     if ( $pageid == get_the_ID() || !is_home() )  
         if (!empty( $pid ))  {
@@ -1130,4 +1136,4 @@

     return $out;
 }
=====

Original issue reported on code.google.com by BMEM...@gmail.com on 29 Jul 2011 at 9:00

GoogleCodeExporter commented 8 years ago
I would like to use the tags as a filter for a gallery, so as to display images 
from a gallery that contain a specific tag. I find that NGG does not keep the 
sort order of the gallery when using [nggtags], and defaults to sorting by pid. 
The following post in WP Support forums addresses this: 
http://wordpress.org/support/topic/plugin-nextgen-gallery-sort-tag-galleries-acc
ording-to-gui-params

Original comment by pablo.en...@gmail.com on 1 Aug 2011 at 3:22