How to Create Container Paragraph Types in Drupal 8

06:36
18146
127
4
0
23
Share
Nov 12, 2016

By: Ivan Zugec
http://webwash.net | http://twitter.com/webwashnet

Read tutorial at http://www.webwash.net/node/260

Modules:

- Paragraphs (https://www.drupal.org/project/paragraphs)
- Entity Reference Revisions (https://www.drupal.org/project/entity_reference_revisions)

In the last Paragraphs tutorial (http://www.webwash.net/node/259), you were introduced to the module and we created a basic paragraph type called Content. We only skimmed the surface of what the module can really do. To utilize Paragraphs to its full potential you need to learn how to create a container paragraph type and nest paragraph items.

The concept of a container is fairly simple. It's a paragraph type that has its own paragraph field on it and allows a user to nest paragraph items.

In this tutorial, we'll create a container paragraph called Banner, it'll have two fields: image and paragraphs.

When a banner paragraph is created and an image is uploaded, the image will be displayed as a background style. Now, I do understand there're multiple ways of doing this, but for simplicity we'll set it using a background style on the paragraph element.

All nested paragraphs will be rendered inside the container and displayed with the background. If you want to add any other settings, i.e., parallax configuration, you would place it on the container paragraph.

Tags

Hi! I'm Karim Boudjema, the developer and site-builder of this site. I'm currently working as a freelance Drupal developer.

I was wondering how could I giving back to the Drupal community all what it gave to me during the last 10 years, that's how the idea of this site came to me ... (read more)

Hi! I’m Santiago Rico, the web designer and themer of this site.

When Karim proposed me to design and theme this site for the Drupal community, I accepted immediately because the community is the main reason why I love Drupal so much.