views:

475

answers:

2

I have drupal6,cck,views,imagecache.

category_type gallery contain a CCK node reference to a category_type images and In this Images there is a cck file (image) field.

I know how to create a view which will display a list of galleries. BUT question is .. HOW can I display a list of galleries with a THUMBNAIL that is made of first image available inside that gallery. And I don't want to add a extra field for gallery (in category_type) like "preview pic" Just want then to be displayed by reference.

Example: If I create a gallery with one picture inside... I want this picture to be my gallery thumbnail.

If I create a gallery without image, there will be no thumbnail ... or default "notavailable" picture.

IF I create a galleyr with many images / remove them /etc.. wanna make sure that first available picture in gallery is gonna be it's thumbnail.

please help ;)

+1  A: 

You might be able to do this in a view, but if you want even your basic gallery node to show an image from one of the child nodes you could do something like this in a file called node-gallery.tpl.php where gallery is the content type machine name:

// load the node reference
if ($child = node_load($node->field_nr_child[0]['nid'])):

  // ... and just print the image from that child node
  print $child->field_image[0]['view'];

endif;

You could also randomize which child you show or show only the most recent child with some foreach fun. You might want to override where the content is displayed so you have more control over formatting but this should get you started.

You can also check out this great screencast I just found looking for something else. I think it does exactly what you want without the custom code: http://www.lullabot.com/articles/photo-galleries-views-attach

Jeremy Heslop
A: 

In CCK image field you must set Default Image ("notavailable" picture).
After this you can:
1. theme node as Jeremy Heslop sayd - node theming;
2. if you make views of Gallery by row style="Fields', then click link on Theme:Information, select appropriate theming file, add it to theme folder, and theme one field (for example, Title) changing it to thumbnailed and linked image (taked from referenced "Images");
3. In Views add Relationships, that will connect "Gallery" with "Images", and show 1 image in field.

Nikit