Is there a way to display image-galleries in reverse order.
I have galleries shown with a rewritten fgallery.module but I want to reverse the view order

Today it list the gallery like this!

gallery1
--date 2007.01.22
--date 2007.01.26
--date 2007.02.02
--date 2007.02.04

I want it to list like this (reverse order)

gallery1
--date 2007.02.04
--date 2007.02.02
--date 2007.01.26
--date 2007.01.22

I could use "Weight" option but when I come up to more than 20 sub-galleries it will be the same problem I think.
Got a tip that it probably will work to override the image_gallery.css ... But how?

The image_gallery.css looks like this:

ul.galleries { 
  list-style-type : none;
  margin : 0;
  padding : 0;
}

ul.galleries li { 
  background : #181818;
  border : 1px #181818 solid;
  color: #acacac;
  margin : 1em 0;
  padding : 1em;
}

ul.galleries li img { 
  float : left;
  padding-right : 4px;
  margin-right : 4px;
}

ul.galleries li div.count { 
  clear : both;
}

ul.galleries h3 { 
  margin : 0;
  padding : 0;
}

ul.images { 
  list-style-type : none;
  margin : 0;
  padding : 0;
}

ul.images li { 
  float : left;
  margin : 1em;
}

Comments

InterceptPoint’s picture

I posted the same question yesterday at http://drupal.org/node/120327 and am still waiting for some guidance. So I'm hoping that one of us gets a bite.

jody lynn’s picture

I think you could change it in function image_gallery_page within image_gallery.module

Maybe something like changing

 for ($i=0; $i < count($galleries); $i++)  

to

 for ($i=count($galleries); $i >=0; $i--)

Just an idea (haven't tried it).

--Zivtech--

blicod’s picture

Thanks for the tip but it didn´t work for me.
Tried to create a new gallery with sub-galleries but it still show the sub-galleries in alphabetical order.

Any other suggestions?

InterceptPoint’s picture

Have a look here at this. I think this is the function in Image Gallery where the image references are put into the images array.

$images = array();
  if ($tid) {
    $result = pager_query(db_rewrite_sql("SELECT n.nid FROM {term_node} t INNER JOIN {node} n ON t.nid=n.nid WHERE n.status=1 AND n.type='image' AND t.tid=%d ORDER BY n.sticky DESC, n.created DESC"), variable_get('image_images_per_page', 6), 0, NULL, $tid);
    while ($node = db_fetch_object($result)) {
      $images[] = node_load(array('nid' => $node->nid));
    }

This is just an SQL query that includes "ORDER BY n.sticky DESC, n.created DESC". Perhaps we could make it ORDER BY n.sticky DESC, n.created DESC ASCENDING or something like that and it would load the images up in reverse.

Well I tried the ASCENDING hack. It didn't break Image Module but it didn't fix it either.

We need a PHP/Drupal wiz to give us a hand.

jody lynn’s picture

 function image_gallery_page($type = NULL, $tid = 0) {
  $galleries = taxonomy_get_tree(_image_gallery_get_vid(), $tid, -1, 1); 

The function is calling taxonomy_get_tree which automatically orders the taxonomy array by weight and then alphabetically. You could add array_reverse(taxonomy_get_tree... ) and try to turn the whole thing backwards.

--Zivtech--

blicod’s picture

<?php
function image_gallery_page($type = NULL, $tid = 0) {
  $galleries = array_reverse_taxonomy_get_tree(_image_gallery_get_vid(), $tid, -1, 1);
?>

Tried that and no effect. Code didn´t break

blicod’s picture

<?php
function image_gallery_page($type = NULL, $tid = 0) {
  $galleries = array_reverse_taxonomy_get_tree(_image_gallery_get_vid(), $tid, -1, 1);
?>

Tried that and no effect. Code didn´t break

InterceptPoint’s picture

Good idea but it didn't do the trick.

In my case the photos are ordered in descending order by the node reference with the largest node number first. This ordering may be independent of any ordering of the photos in the images array of the Image Gallery module. So .. is there a way to reorder the display of nodes?

jody lynn’s picture

Are we trying to reorder the images within the gallery or are we reordering the list of sub-galleries for the gallery? I am thinking maybe you guys are wanting two different things? Let me know... I have some new ideas and I hope they're getting better!

--Zivtech--

blicod’s picture

hehe...sub-galleries

and images to... But there is an other thread for that.

Take a look at the site nottie.net/gallery and you´ll see that the sub-galleries is named by date and the oldest date come at the top of the list. I like to reverse this.

InterceptPoint’s picture

I bet the subs are in alphabetical not chronological order. Add another one to check.

jody lynn’s picture

function image_gallery_page($type = NULL, $tid = 0) {
  $galleries = taxonomy_get_tree(_image_gallery_get_vid(), $tid, -1, 1);
  $galleries=array_reverse($galleries);

Try adding the line like that.

--Zivtech--

InterceptPoint’s picture

I'm assuming this change, if it works would affect the Gallery or Sub-Gallery order. So my question is: to change the order photos are displayed within a Gallery do I have to hack the image module or the image gallery module. I'm betting it's the image module.

InterceptPoint’s picture

But I'm really interested in fixing both the album and the photo order.

My preferences:
Galleries should be listed chronologically with the most recent on top. Currently they are alphabetical. Perfection would be a toggle.
Photos within galleries should be listed in reverse chronological order with newest last.

But my main focus is photo order. I can live with alphabetical albums.

blicod’s picture

Photos within galleries should be listed in reverse chronological order with newest last.

Can´t you just add the images in reverse chronological order. Then you got the last added image first;)
That is what I do today:D

jody lynn’s picture

$images = array();
  if ($tid) {
    $result = pager_query(db_rewrite_sql("SELECT n.nid FROM {term_node} t INNER JOIN {node} n ON t.nid=n.nid WHERE n.status=1 AND n.type='image' AND t.tid=%d ORDER BY n.sticky DESC, n.created DESC"), variable_get('image_images_per_page', 6), 0, NULL, $tid);

This is within function image_gallery_page in the image_gallery.module. Just change where it says "ORDER BY n.sticky DESC, n.created DESC" to "ORDER BY n.sticky DESC, n.created ASC" and that should put the images in ascending order based on creation date.

You can change your gallery order just by using weights. It looks a little complicated to list those chronologically.

--Zivtech--

blicod’s picture

Thanks... for the image ASC

You are correct. I can change the weigt but when I come to more then 20 sub-galleries (-10 to 10) it will not function anymore

So do someone have any idea?

InterceptPoint’s picture

I made the change from DESC to ASC and that changes the thumbnails on the page listing my photo albums to show the oldest thumbnails rather than the newest. That's progress. But alas, the photos are still in the wrong order (newest is still at the top). I'm going to try the ASC change in the images module. That has to work.

InterceptPoint’s picture

It is in the Image Gallery module. Here is the change (DESC to ASC) that sets the photo order to oldest photo first. This is the modified code.

 $images = array();
  if ($tid) {
    $result = pager_query(db_rewrite_sql("SELECT n.nid FROM {term_node} t INNER JOIN {node} n ON t.nid=n.nid WHERE n.status=1 AND n.type='image' AND t.tid=%d ORDER BY n.sticky DESC, n.created ASC"), variable_get('image_images_per_page', 6), 0, NULL, $tid);
    while ($node = db_fetch_object($result)) {
      $images[] = node_load(array('nid' => $node->nid));
    }

where n.created. DESC was changed to n.created.ASC. This changes the order from DESCENDING to ASCENDING.

Works for me.

InterceptPoint’s picture

Much thanks for the help on the image order issue.

blicod’s picture

$galleries = taxonomy_get_tree(_image_gallery_get_vid(), $tid, -1, 1);
$galleries=array_reverse($galleries);

This line fix the sub-gallery order in flash gallery module
..so it will probably fix the image gallery module

Many thanks to Lynn and InterceptPoint

InterceptPoint’s picture

That should have read n.create DESC was changed to n.created ASC.

mariagwyn’s picture

Is it possible to do this in template.php so that the change is not overwritten with each upgrade? I tried to take the whole function, but got a "cannot redeclare" error.

Thanks,
Maria

t10barba’s picture

Add arsort() in image_gallery_page() function on image_gallery.module file

$galleries = taxonomy_get_tree(_image_gallery_get_vid(), $tid, -1, 1);
arsort($galleries); /* order by tid (inverse): 10, 9, 8, 7... */

--
IGUANA!