0

I want to construct a view which will include nodes from several content types.

For each different content type, I want to display different fields (say an image for a type, a video for another, some different text for others)

Let me show you the example I want to achieve:

row 1 is "image", row 2 is "video", row 3 is "event" content type. So,

  1. John shared a new image: IMAGE

  2. Jane is watching a video now: VIDEO

  3. Jack is thinking "this day is sunny".

1

Have you tried anything so far?

Try creating your view and select unformatted list as your style. Add your fields as you would normally. Under format, select settings and make sure that "Hide empty fields" is clicked.

If you fetch lets say the first five nodes from content types Images, Videos, Statuses then each row of the view should look like this:

==row 1==
John shared a new image: IMAGE
John is watching a video now: VIDEO
John is thinking "this day is sunny".

==row 2==
Jane shared a new image: IMAGE
Jane is watching a video now: VIDEO
Jane is thinking "this day is sunny".

==row 3==
...

but if row 1 is a result from the Video content type then the fields image and status should be empty and will be hidden since you clicked that format option before. Try it and see if it works for you.

  • Thanks, I am already doing it. But I have many content types, and adding all the fields is a little bit complicating the view. It is not easily maintainable. What I would prefer is to control each content type's display in the view. You will say that I should then use display modes (default, teaser, etc) of content types. It would be ok if I could add some custom fields to the display mode of the type. I will try Display Suite module for it. Will see if I can achieve my goal. – Sinan Erdem May 20 '12 at 15:30
  • Well if you need that kind of control then I guess you should create a custom template for your view. You can add the content type as a field and inside your template use it for creating different outputs. Although it won't change how complicated your view is. You would still have to add all the fields from the different content types. – Perisdr May 21 '12 at 9:18
0

So far, the best option is to use a special patch to Views. The patch is located on: http://drupal.org/node/357082

This patch makes the filters take values from contextual filters.

So, for my case, I created several custom contextual filters. Then I got these returned values in different filters. Once they are filters, I was able to AND/OR them.

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.