0

This question is an exact duplicate of:

I have a content type with dynamic content block section. Each block section is managed by paragraph bundle.

Let's explain using an example to make more clear-

  1. Content type name is Employee.
  2. A paragraph field is added in the employee content type. Field machine name is field_body_contents
  3. All paragraph bundle is showing in dropdown and admin can select the paragraph bundle to add content with the employee.
  4. We have created the template for each paragraph bundle and these are rendering perfectly on the template file.

Now there is a new case that we need to embed the views data with the field_body_contents dropdown so that admin can section views from the dropdown to inject views data between paragraph bundle.

marked as duplicate by Clive 7 Mar 28 at 9:15

This question was marked as an exact duplicate of an existing question.

  • I tried this a few months back, and the paragraphs module does not appear to be set up to do this. I dug fairly deep in the code to confirm. – Jaypan Mar 28 at 7:44
  • Please don't delete questions that have been closed just to ask them again. If you have more information that would make the question clear enough to be answered, please edit the original post. Thanks – Clive Mar 28 at 9:15
0

The way I've done this is to preprocess the paragraph and alter the $variables['content'] to contain the views data/render array you've retrieved programatically:

function HOOK_preprocess_paragraph(&$variables) {
  if ($variables['paragraph']->type->target_id == 'yourparagraph') {
     //code to get the view you want
     ...
     ...
     $variables['content']['view_content'] = $theviewdata;

  }
}

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