0

Drupal 8.. This may be a two-part problem. I want to avoid repeated content due to multiple values in a nested paragraph reference, but ALSO put the nested paragraph fields into a custom text field, so I can change how they're rendered.

I have a content type "episode", with a field referring to paragraph "section", containing several fields. One of those fields inside "section" is a nested reference to a paragraph called "source".

I created a view for content type "episode". It pulls the results of "Section" matching a content ID contextual filter. Then I added a reference to the paragraph "section", so I could get individual fields instead of a fully rendered value (I want to do this myself in a custom text field). I also created a reference for the "source" paragraph, to the "section" paragraph.

I'm able to add all the paragraph and nested paragraph fields, but the nested "source" fields are showing blank in the preview below, and it duplicates entries based on number of 'sources' I confirmed the paragraph fields are all set to show in the "manage display" for both paragraphs.

I then tried to see if there was a way I could just use the rendered paragraph "source" on the page. This shows the information, and I can set it to "Display all values in the same row" to eliminate duplicates.

But this prevents exactly what I'm trying to do: custom style the presentation of the information

What I want is to end it all with a custom field something like this:

<div class="classname">{{ field_section_timestamp }} 
<h3>{{ field_section_title }}</h3>
<p>{{ field_section_description }}</p>
<h4>Sources</h4>
<em>{{ field_source_author }}</em><a href="{{ field_source_link }}">{{ field_source_title }}</a>

...And then apply whatever settings that get the sources to show as a list and not duplicate the entire section over-and-over, giving me something like this:

Episode
 - Section 1
    - Source 1
    - Source 2

 - Section 2
    - Source 1
    - Source 2

I know this can be done with the rendered paragraph and multiple field settings checked to "display all values in a row" But...

What I need is change how each field in Paragraph B is rendered - changing the tags.

But when I try to do this by adding the paragraphs as relationships and using individual fields, I get the repeating issue described above. I added the fields to a custom text field with everything, but this generates repeats.

Episode
 - Section 1
    - Source 1 (value blank)

 - Section 1
    - Source 2 (value blank)

 - Section 2
    - Source 1 (value blank)
 - Section 2
    - Source 2 (value blank)

Actually... as I'm typing this out and testing, I'm seeing that the paragraph B values aren't even showing at all. Though they take up space. just no content.

Hopefully this gives enough of a starting point for the question?

2

Seems I found an answer. I suddenly remembered there was something called the Views field View module. I installed it, played around with it until I found a "views" field. I was able to create a second view for the nested paragraph, add it to the first paragraph' view, through the and use a conditional field based off 'parent ID' and got exactly what I was looking for.

For reference, this video shows most everything you'd need to know, for using it:

| improve this answer | |

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.