开发者

Drupal gallery with thumbnail made of first picture

开发者 https://www.devze.com 2022-12-16 07:47 出处:网络
I have drupal6,cck,views,imagecache. category_type gallery contain a CCK node reference to a category_type images

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.

Examp开发者_运维知识库le: 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 ;)


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


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消