2

I have a node type of photo-gallery. Each node has a field collection which contains multiple photo fields and caption fields. I want to create a view showing the 5 most recent photo-gallery nodes but I only want to display one photo field from each without the caption field. How would I do this? I can't seem to figure out how to get only one field from the field collection in the view.

2

There is another solution mentioned in the issue that you reference in your answer that I would say is a good solution.

  1. Add a new view mode. You could use the entity view modes module if you didn't want to code it yourself.
  2. Configure that view mode for your field collection so that it only shows the photo and not the caption.
  3. Don't add a relationship to the field collection because it will cause rows per field collection item.
  4. Configure your view to display the field collection as one of the fields. Select the view mode you created. In the "Multiple field settings" part of the field definition configure it to Display 1 value(s) starting from 0 to just show the first one.
1

To achieve your goal you can create a view with following settings:

SHOW: Field collection item
Display: your display type

then, in new created view:

  1. Relationship: Field collection item: Entity with the [your image field name](your field mashine name)
  2. filter criteria: content type is on of: photo gallery
  3. Fields: field with the image

At that moment your view should showing all images associated with your photo gallery content type and field collection.

to display one photo field from each query just set the pager and sort criteria

Please comment of you face any problems with these settings.

  • I'm not sure this would work in regards to using sort to restrict to only show one row per field collection. – rooby May 20 '15 at 0:56
0

I've solved my issue by applying this patch: http://drupal.org/node/1883946#comment-6918878 Seems like there should be a less hackish way though.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.