Drupal Update – Thoughts: Using Paragraphs in Drupal maintenance support plans 8

When we received the new designs for the Ixis site it was evident that they contained separate design elements which were shared across several pages, from the homepage to departmental landing pages to the “About us” page. We thought this was a perfect use case for the Paragraphs module, which allows site editors to “choose on-the-fly between predefined Paragraph Types… instead of putting all of their content in one WYSIWYG body field.”
Most content types on the new Ixis site contain a Paragraphs field. An editor can create multiple Paragraphs of any defined type and sort them to specify the elements and layout of the node’s content.

Paragraph types can be anything from a simple text block or image to a complex and configurable slideshow. Paragraph types are essentially fieldable entities and the Paragraphs module allows the creation of these types. Each defined type can have it’s own set of relevant fields, all added via the Drupal maintenance support plans UI and exporting to config.
So, to support the elements outlined in our page designs we added Paragraph types for:
Call to action – areas of bold background colour and large text;
Download – a downloadable asset or file;
Gallery – a gallery list of images;
Image – a single, responsive image;
Testimonial – a quote or testimonial;
Text – basic, filtered HTML edited with CKEditor;
Text with Callout – regular body text coupled with a styled “callout”;
Twitter – an embedded Twitter widget;
Video – an embedded video from a 3rd-party site such as YouTube.
All these Paragraph types give editors some flexibility and choice when authoring a page designed with several of these elements.
Styling
The rendered output of Paragraphs entities can be altered using a paragraph.html.twig file in the site’s theme. For example:

{%
set classes = [
‘paragraph’,
‘paragraph–type–‘ ~ paragraph.bundle|clean_class,
view_mode ? ‘paragraph–view-mode–‘ ~ view_mode|clean_class,
cta_style ? ‘cta-style–‘ ~ cta_style|clean_class,
]
%}

{% block paragraph_content %}

{{ content }}

{% endblock paragraph_content %}

The rendered output of each individual Paragraph type can also be affected using a suggested Twig template, for example we have paragraph–testimonial.twig.html for appropriately rendering a testimonial quote and cited author.
In some places we’ve used a field combined with a preprocess to provide multiple variations of the same paragraph. You can see this in action above with the cta_style variable which gives us a standard or inverted dark style for Call to action paragraphs.
Content Migration
During the initial content migration, we migrated directly into a Text Paragraph in the new Paragraphs field for some content types such as blog posts. To do this, we needed a new process plugin:

/**
* Saves D6 Page Body field to D8 Page Paragraph (Textarea) field.
*
* @MigrateProcessPlugin(
* id = “node_paragraph_textarea”
* )
*/
class NodeParagraphTextarea extends ProcessPluginBase {

}
We used a slightly modified version of the example plugin in this article by Amit Goyal. Then in our migration.d6.node__blog.yml we removed:


body/format:
plugin: migration
migration: d6_filter_format
source: format
body/value: body
body/summary: teaser
…and replaced with the new process plugin to instead migrate the source body into the Paragraphs field:


field_paragraphs:
plugin: node_paragraph_textarea
source: body
…In summary, Paragraphs is a great alternative to a single WYSIWYG editor for site editors who want to be able to lay out complex pages combining text, images, video, audio, quotes or any other advanced component. Here’s some further reading:
Improve user experience with Paragraphs for Drupal maintenance support plans 8
Paragraphs project page
Paragraphs in Drupal maintenance support plans 8 documentation


Source: New feed

This article was republished from its original source.
Call Us: 1(800)730-2416

Pixeldust is a 20-year-old web development agency specializing in Drupal and WordPress and working with clients all over the country. With our best in class capabilities, we work with small businesses and fortune 500 companies alike. Give us a call at 1(800)730-2416 and let’s talk about your project.

FREE Drupal SEO Audit

Test your site below to see which issues need to be fixed. We will fix them and optimize your Drupal site 100% for Google and Bing. (Allow 30-60 seconds to gather data.)

Powered by

Drupal Update – Thoughts: Using Paragraphs in Drupal maintenance support plans 8

On-Site Drupal SEO Master Setup

We make sure your site is 100% optimized (and stays that way) for the best SEO results.

With Pixeldust On-site (or On-page) SEO we make changes to your site’s structure and performance to make it easier for search engines to see and understand your site’s content. Search engines use algorithms to rank sites by degrees of relevance. Our on-site optimization ensures your site is configured to provide information in a way that meets Google and Bing standards for optimal indexing.

This service includes:

  • Pathauto install and configuration for SEO-friendly URLs.
  • Meta Tags install and configuration with dynamic tokens for meta titles and descriptions for all content types.
  • Install and fix all issues on the SEO checklist module.
  • Install and configure XML sitemap module and submit sitemaps.
  • Install and configure Google Analytics Module.
  • Install and configure Yoast.
  • Install and configure the Advanced Aggregation module to improve performance by minifying and merging CSS and JS.
  • Install and configure Schema.org Metatag.
  • Configure robots.txt.
  • Google Search Console setup snd configuration.
  • Find & Fix H1 tags.
  • Find and fix duplicate/missing meta descriptions.
  • Find and fix duplicate title tags.
  • Improve title, meta tags, and site descriptions.
  • Optimize images for better search engine optimization. Automate where possible.
  • Find and fix the missing alt and title tag for all images. Automate where possible.
  • The project takes 1 week to complete.