0

I've got a content type that contains fields like this:

title
field collection
body
link

The field collection contains:

image
text

The field collection is going to be for 3 iterations in one node. In views this is the desired output:

title
field collection 1 image
field collection 1 text
field collection 2 image
field collection 2 text
field collection 3 image
field collection 3 text
body
text
link

I've set the relationship in views and retrieved the field collection fields. The problem I'm running into is it's duplicating all the single fields for every field collection item. The output looks like this:

title
field collection 1 image
field collection 1 text
body
text
link
title
field collection 2 image
field collection 2 text
body
text
link
title
field collection 3 image
field collection 3 text
body
text
link

How can I get it to draw all the field collection fields without duplicating the rest of the fields along with it?

enter image description here

1
  • Have updated my answer with explanation and solution...
    – CodeNext
    Oct 11, 2016 at 10:30

1 Answer 1

1

I think this is not the right views set-up for what you want to display, you have done wrong field selections. To see direct solution scroll down to Solution section.


What is the Issue:

If you see your views field setting it is like as follows,

  • Content: title
  • field collection item: Bubble title
  • field collection item: Bubble image
  • Content: Body
  • Content: Link

So, here in above view set-up the field collection item is just one field, so through views you are just accessing one field, hence, the concept of field collection module dies here. Here, it is just a field which you are accessing through the Relationship.

Now, why you are observing what you are observing in the view,

Your Node: Following is the correct representation of your Node, Not what you have shown in your Question. Your node has FIVE main fields- and whatever inside the field collection field are field-in-field.

   1. title
   2. field collection
     2.1a field collection 1 image
     2.1b field collection 1 text
     2.2a field collection 2 image
     2.2b field collection 2 text
     2.3a field collection 3 image
     2.3b field collection 3 text
   3. body
   4. text
   5. link

Now, you have set your views like as follows,

   1. Content: title
   2.xx field collection item: Bubble title
   2.xx field collection item: Bubble image
   3. Content: Body
   4. Content: Link

I think by this time you would have understood why you are getting what you are getting in views.

Let me explain:

Cycle:1 Views start the first cycle and iterates from its Fiest field to Fourth field, so it will showing following fields:

   1. Content: title
   2.1a field collection item: Bubble title
   2.1b field collection item: Bubble image
   3. Content: Body
   4. Content: Link

Cycle:2 Now, views works stops there, But wait, Views discover that another 2.xx and 2.xx are there on node, So it starts second cycle so again from TOP to Bottom,

   1. Content: title
   2.2a field collection item: Bubble title
   2.2b field collection item: Bubble image
   3. Content: Body
   4. Content: Link

Cycle:3 Then again third cycle, So that why you are getting this,

   1. Content: title
   2.3a field collection item: Bubble title
   2.3b field collection item: Bubble image
   3. Content: Body
   4. Content: Link

So whatever views are showing it showing correct as per your field selection, But that is not what you want, please see the solution in following section, it is very simple.


Solution:

The solution is very simple: You just need a field which represent the entire field collection of that node and luckily that is present in views.

  • Remove the relationship: You do not need the relations ship.
  • Modify the field: Instead of selecting individual field, select entire field collection which you can find as Content:nameOfFieldCollection. in my case it is FC101.

enter image description here

Example:

I have created Content type with:

1. Title
2. Body
3. Field collection(FC101)
   - Image
   - text
   - Image
   - text
   - Image
   - text
4. Body2

My views set-up:

enter image description here

Output in VIEW:

1. Title
2. Body
3. Field collection(FC101)
   - Image
   - text
   - Image
   - text
   - Image
   - text
4. Body2
0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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