I have a (hopefully) quick question related to the HOW TO: Create an image gallery using CCK and Views (not Image Module) tutorial in the Handbook.
Hopefully you're familiar with the this "building blocks" way of putting together a Drupal image gallery.

My goal is to create behavior more similar to how the Image module's gallery functions, with a main "Gallery" page (mysite.com/gallery) that will list/link to all of the "sub-galleries" or albums within it, including the title of the gallery, and an imagecache thumbnail of the latest submitted photo in each category. Ideally a front end for gallery management as well (like Image module's), but that's a whole other story for another time haha ;) Let me preface this by saying I'm not a programmer.

So, on to the question: I now have a group of "sub galleries" managed by taxonomy terms, but they are all separate entities from each other. I was wondering if anyone could help me setup a way to show a main/parent listing of the "gallery categories" I've setup now with taxonomy (either with a View or with some custom "glue" code)?

I've tried my hand at creating a new View for this, and got it to work "somewhat", but am stumped on how to limit the display to only the most recent node in each taxonomy term (I can get the view to print out the associated taxonomy term along with each image, but it still prints all of the images/terms - I can't find anything in Views to filter it to just the latest one of each). I also tried entering PHP code manually to query the taxonomy (such as customizing code from here and the code snippet from pages 233-234 of my Pro Drupal Development book), but couldn't get anything to display (I don't really have any idea what I'm doing when it comes to jumping into the PHP haha). I pasted the aforementioned PHP code (with my own taxonomy term IDs) into a new Page node with PHP input type (not sure if that's the right way to go about that - it didn't give any errors, just displayed nothing... not sure where else to make a PHP/glue-code driven page).

Anyhow, any help would be greatly appreciated. I think a nice "gallery home page" tying all of the sub galleries/albums together would make a nice finishing touch for the great technique in this howto :D My most current version of the site is on my local server (the Views now mangled from trial and error), but if you'd like to see what I had before, feel free to have a look at the gallery (note: not internet exploder 6/7 compliant yet haha).

-- Dave

Comments

dnewkerk’s picture

Hoping someone can help... I'm pretty stuck on this.
Thanks very much in advance :)

-- Dave

bassio’s picture

Did you try to limit the node numbers to one and sort by date created descending to achieve what you want?

dnewkerk’s picture

If I understand correctly, you mean setting the "Nodes per Page" in the Page settings to 1, correct? I've tried this and it limits the View to displaying only 1 single node teaser in total (e.g. not one representing each taxonomy term - just one node by itself). If this part of the setting is right but some other additional setting makes it work, please let me know.

So far as the setting in Sort Criteria, yes, I have it set to Node: Created Time in descending order.

Here's the basic "format" that I'm trying to accomplish.. basically the typical photo gallery setup in any gallery system: http://gallery.menalto.com/index.php?q=gallery
Or something like the Drupal module Acidfree (demo), or the Image module's gallery (neither of which I prefer to use at this point, since Image is too inflexible, and Acidfree is still dev for 5.x).

To best communicate all of my settings, here is my exported View, with the current settings:

  $view = new stdClass();
  $view->name = 'Gallery';
  $view->description = 'Photo gallery';
  $view->access = array (
);
  $view->view_args_php = '';
  $view->page = TRUE;
  $view->page_title = 'Photo Gallery';
  $view->page_header = '';
  $view->page_header_format = '1';
  $view->page_footer = '';
  $view->page_footer_format = '1';
  $view->page_empty = '';
  $view->page_empty_format = '1';
  $view->page_type = 'list';
  $view->url = 'gallery';
  $view->use_pager = TRUE;
  $view->nodes_per_page = '1';
  $view->sort = array (
    array (
      'tablename' => 'node',
      'field' => 'created',
      'sortorder' => 'DESC',
      'options' => 'normal',
    ),
  );
  $view->argument = array (
  );
  $view->field = array (
    array (
      'tablename' => 'node_data_field_image',
      'field' => 'field_image_fid',
      'label' => '',
      'handler' => 'content_views_field_handler_ungroup',
      'options' => 'thickbox][gallerythumb',
    ),
    array (
      'tablename' => 'term_node_2',
      'field' => 'name',
      'label' => '',
      'options' => 'link',
    ),
  );
  $view->filter = array (
    array (
      'tablename' => 'node',
      'field' => 'status',
      'operator' => '=',
      'options' => '',
      'value' => '1',
    ),
    array (
      'tablename' => 'term_data',
      'field' => 'vid',
      'operator' => 'AND',
      'options' => '',
      'value' => array (
  0 => '2',
),
    ),
    array (
      'tablename' => 'node',
      'field' => 'type',
      'operator' => 'OR',
      'options' => '',
      'value' => array (
  0 => 'image',
),
    ),
  );
  $view->exposed_filter = array (
  );
  $view->requires = array(node, node_data_field_image, term_node_2, term_data);
  $views[$view->name] = $view;

-- Dave

guardian’s picture

subscribing

natem50’s picture

Were you ever able to get a resolution to this? I am new to Drupal myself and am struggling with the same problem you are and have found no resolution yet.

dnewkerk’s picture

Just a little... I had to take a break from this issue and work on some other aspects of my project, but plan to get back to figuring this out soon.
I did make some minor progress though, in that I found a PHP snippet which you can embed in a PHP node, block, tpl.php file, etc, which gives a listing of the terms in a given taxonomy vocabulary... this is at least a start - ideally I want to try learning how to manually add the PHP to pull in a image thumbnail from each respective term and display it next to the term. There was also a View on the thread I found this on, but I couldn't get it to work yet (I'll post the link if I can find it). I'm not sure yet if/how this code will handle a vocabulary with multiple hierarchy.

I also thought of a compromise on the layout for my gallery that might be acceptable: I would list out the terms with the PHP snippet (or maybe with one of the various taxonomy browsing modules), and below that show a grid of the latest 10-20 photos overall (so I don't get my "latest photo next to each album" but at least I get links to all the albums (terms) and photos from the gallery so the listing page isn't completely dull. I also thought I'd try looking at how Image module's gallery pulls its thumbnails in (unlikely I'll understand, but worth a look).

I experimented more with Image module's gallery, and found it to be pretty decent though very inflexible - and was disappointed when I realized that it forces you to use its pre-defined URL paths (image/tid/#) and ignores anything from Pathauto. I looked at the epic thread about overriding its theming as well and was substantially frightened :P

Anyhow here's the PHP snippet:


$vid = 2;  // Set the vid to the vocabulary id of the vocabulary you wish to list the terms from
$items = array();
$terms = taxonomy_get_tree($vid);
foreach ( $terms as $term ) { 
    $count = db_result(db_query("SELECT COUNT(nid) FROM {term_node} WHERE tid = %d", $term->tid)); 
    $items[] = l($term->name, "taxonomy/term/$term->tid") . " ($count)";
}
if ( count($items) ) {  print theme('item_list', $items);}

Of course, if any Drupal gurus are willing to help nudge me in the right direction, I'd be very grateful :)
I've been trying to learn some PHP (PHP video tutorials) but I'm still light years off from knowing what I'm doing haha.

-- Dave
absolutecross.com