2

I have a content type (Testimonials) with a title field and a field configured as a Paragraph. I'm trying to create a view showing all the nodes of this content type.

In the Add field section of the view creation page, I can only select the title field. I cannot select the fields that are part of the paragraph.

How can I show them in the view?

I tried with Add relationship (paragraph referenced from field_dl_testimonial_components). It works but I get duplicate records in my view (1 record per paragraph).

These are the paragraphs visible in the node edit form.

screenshot

2 Answers 2

4

When working with views and entity references, which is what paragraph fields are essentially, it is preferred (in my opinion) to use rendered entities instead of relationships because of the exact issue of duplication.

Rendered entities lets you add/remove fields per view mode of the entity in a separate form.

First you must add the field of the paragraph (the one you placed on the node) to the view, choose 'Rendered Entity' and select the view mode you want (the choice of view mode depends on if you use it in other places and wouldn't want to affect appearance in these other places, or the opposite if you want to reuse appearances):

enter image description here

Then go to the paragraph management page, manage displays, and select your view mode (you can add additional view modes at the bottom)

enter image description here

From here you can configure the appearance of the paragraph like you would a content type, such as adding/removing fields.

The end result will have a view with your node titles and the paragraphs with the fields you configured in the paragraph's view mode.


Edit

In the case that a single paragraph type is needed from the field, then relationship would be appropriate here, you just need to add a filter. Add 'Type' filter and choose your paragraph type. type filter

10
  • Thx for you answer, ... some pointers though: 1: Paragraphs has only 1 view mode: 'preview', you can't add extra. 2: We already use the 'preview' mode to describe the component (content type > manage form display > paragraph field > widget settings: edit mode: preview). 3: Even if we do have multiple view modes, the view would still display 'all' the components that were added to the Paragraph bundle. A solution is to create 1 field per Paragraph bundle and limit them to 1 component but that diminishes the functionality of Paragraphs (no rearranging of components, fixed position on the page)
    – kevinius
    Commented Apr 28, 2017 at 8:23
  • i have added a screenshot of my setup... As you can see, if i add the component main field to the view and choose 'rendered entity' it will display 'all' the components.
    – kevinius
    Commented Apr 28, 2017 at 8:30
  • @kevinius So you want a single field from a single paragraph? How would you know which paragraph to use?
    – Nir Yariv
    Commented Apr 28, 2017 at 10:29
  • Hey, as you can see in the screenshot, i have 5 different paragraphs. In my example i would only need C2A: visual descriptor.
    – kevinius
    Commented Apr 28, 2017 at 11:45
  • @kevinius Is there only one C2A paragraph per node? If so then a relationship would be useful here, you just need to add a filter to the view. Update your question with this specific requirement and I will update the answer.
    – Nir Yariv
    Commented Apr 28, 2017 at 12:38
0

Try this filter: enter image description here

Pardon my french, it means "is the last revision", check and apply.

Your Answer

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

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