Hi Folks

I'm attempting to create a block that will show the thumbnails from a given gallery in the sidebar on the client's site.

Here's the original page I'm converting. Here's my development page. (never mind the design glitches for now)

What I want it to do is on "galleryx.html" (where x is a numeric value identifying that particular gallery -these are hardcoded based on the client's old site), the nav will show a thumbnail of each of the photos in that gallery. When you view any of the photos in that gallery, it still shows the thumbs from that gallery. This is the way the client's old site works, and it makes logical sense.

Through much frustrated Googling, I found some code that kind of did what I wanted. From that example, I created the following "module"(?)

/**
 * Implementation of hook_block.
 *
 * Offers 3 blocks: latest image and random image and a thumbnail gallery navigation
 */
function image_block($op, $delta = 0) {
  switch ($op) {
    case 'list':
      $block[0]['info'] = t('Latest image');
      $block[1]['info'] = t('Random image');
	  $block[2]['info'] = t('Gallery Thumbnail Nav');

      return $block;
    case 'view':
      if (user_access('access content')) {
        switch($delta) {
          case 0:
            $images = image_get_latest();
            $block['subject'] = t('Latest image');
            $block['content'] = l(image_display($images[0], 'thumbnail'), 'node/'.$images[0]->nid, array(), NULL, NULL, FALSE, TRUE);
            break;
          case 1:
            $images = image_get_random();
            $block['subject'] = t('Random image');
            $block['content'] = l(image_display($images[0], 'thumbnail'), 'node/'.$images[0]->nid, array(), NULL, NULL, FALSE, TRUE);
            break;
          case 2:
            $images = image_get_gallerynav();
            $block['subject'] = t('Gallery Nav');
            //$block['content'] = l(image_display($images[0], 'thumbnail'), 'node/'.$images[0]->nid, array(), NULL, NULL, FALSE, TRUE);
			$block['content'] = whistlerbrides_block_image_list();
            break;
        }
      }
      return $block;
  }
}

Which calls


/**
 * Fetch the current N image(s).
 */
function whistlerbrides_block_image_list() {

  $images = image_get_gallerynav(16, $this_nid);
  $output = '';
  foreach ($images as $image) {
   $output .= l(image_display($image, 'thumbnail'), 'node/'.$image->nid, array(), NULL, NULL, FALSE, TRUE);
  }

  return $output;
}

Which calls

/**
 * Fetch the images from the currently selected gallery.
 */
 
function image_get_gallerynav($count = 16, $tid=0) {
			
  if ($tid != 0) {
    $result = db_query_range(db_rewrite_sql("SELECT n.nid FROM {term_node} tn LEFT JOIN {node} n ON n.nid=tn.nid WHERE n.type='image' AND n.status=1 AND tn.tid=%d ORDER BY n.sticky DESC, n.changed DESC"), $tid, 0, $count);
  }
  else {
    $result = db_query_range(db_rewrite_sql("SELECT n.nid FROM {node} n WHERE n.type='image' AND n.status=1 ORDER BY changed DESC"), 0, $count);
  }
  $output = array();
  while ($nid = db_fetch_object($result)) {
    $output[] = node_load(array('nid' => $nid->nid));
  //print '<p>' . node_load(array('nid' => $nid->nid)) . '</p>';
  }
  return $output;
}

What I get for output is what you see in the example. I see thumbnails (hallelujah!) but they're from ALL the galleries. The problem is, of course,

function whistlerbrides_block_image_list()

There's nothing in this that collects "this current gallery". Clearly the code exists here someplace -- this is how the normal galleries work! I just want to move the gallery behaviour out of the main content area and into the nav section -- everything else should behave normally, I think. (except for my Issue regarding making the thumbnails appear as black and white (monochrome)...

So, to clarify, I need to figure out the correct variable that says "I am now viewing an image in Gallery X". I've tried $node->nid (which I've seen everywhere) like this:

function image_get_gallerynav($count = 16, $node->nid) {

And it throws an error.

I've tried snagging the current nid using $this_nid = arg(1) , but that doesn't get the gallery; it gets the -current- nid.

Help? Please?

Comments

jfriesen’s picture

Still looking for assistance on this issue.

jfriesen’s picture

No help?

jfriesen’s picture

How incredibly disappointing that no-one can even so much as respond to this issue. This speaks volumes for this community and the usefulness of Drupal in general.

alanburke’s picture

Did you get this issue sorted?

From looking at the links, it seems yes.

Of so, what changes did you make to the code you provided?

Regards
Alan

jfriesen’s picture

Sorted? Heavens, no.

I abandoned the whole idea completely and painstakingly created custom blocks for each gallery navigation in html. The client would have to upload a picture, copy the link to the thumbnail, and hand-code that into the custom block for each gallery.

Naturally, the client is cancelling the project, because the workflow necessary to make his site function as expected was far too cumbersome.

If Drupal is going to be useful at all, it needs to be the effortless "push-button" publishing that it purports to be. Needless to say, I won't be using Drupal in the future.

alanburke’s picture

I'm sorry that it didn't work out,

Not being much of a coder, I can't be of direct help, you these two items may have been of use

http://www.lullabot.com/articles/how_to_build_flickr_in_drupal

http://willwyatt.com/node/1568#comment-688

They don't do exactly what you want, but they may be be able to point you in the right direction.
They were useful to me in solving my problems.

Regards
Alan
If you have abandoned Drupal, what have you gone with?
FWIW, I have been frustrated by Drupal many times in this last year.
But I'v been amazed many many more times. I generally find that I contstantly find ways to fix problems, and achieve cetain outcomes, that would have saved hours of frustration, a few weeks AFTER giving up and going with a workaround.

alanburke’s picture

Status: Active » Fixed

Closing my old issues.
This Stuff can be done with Views module these days

Anonymous’s picture

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for two weeks with no activity.