BUILDING FLEXIBLE PAGE-LAYOUTS WITH DS & PARAGRAPHS

Pieter Mathys - @mathysp - dazzle

First of all

No need to take pictures!

Just follow along here:

bit.ly/dsparagraphs

 

This presentation is for everyone!

Beginners, Experts, ...

Summary

  • Who am I?
  • What's this all about?
  • Common use cases
  • Setup D8 + DS + Paragraphs
  • Configuring Display Suite
  • Configuring Paragraphs
  • Bringing it together
  • Reusing DS + Paragraphs
  • Known issues
  • Q&A

 

Who am I?

Pieter Mathys

  • Frontend Dev
  • Themer
  • Sitebuilder
  • Teacher

Born in

Duffel

Belgium

Building websites since 2010

Work for

We are hiring! - dazzle.be/jobs

What's this all about then?

The Goal

We want Websites with
Complex Layouts
that are

Easy to use

Easy to maintain 

Offer lots of flexibility

But we have a Problem

It's easy to...

... build complex layouts

... give the client lots of power

 

But combining those 2?

That spells trouble!

The answer is simple

Build websites with

  • Display Suite
  • Paragraphs

Display Suite

Layouts

to create our layout templates

 

Fields

to map functionality to a field

Paragraphs

Create reusable "Content Blocks"

Content

Blocks

  • Images
  • Text
  • ...
  • Default Blocks
  • Editable Blocks
  • Views
  • ...

With our powers combined

DS + Paragraphs

=

A strong tool to create advanced Page Layouts

with flexible, reusable Content Blocks

 

Common use cases

Example Site: protime360.eu

Text - Full

Full Width Image

Inline Image

Quote Full Width

Quote Inline

Quote Reference

References a Node

Company Information

View: Homepage Filter

Setup D8+DS+Paragraphs

Setup D8

Install DS

Download from:

https://www.drupal.org/project/ds

$ drush dl ds

 

Enable:

admin/modules

$ drush en ds 

Install Paragraphs

Download from:

https://www.drupal.org/project/paragraphs

$ drush dl paragraphs

 

Enable:

admin/modules

$ drush en paragraphs

Configuring

Display Suite

Parts

  1. Settings
  2. Layout
  3. DS Fields
  4. DS Classes
  5. Layout Wrappers
  6. Field Templates

 

Main Settings

Main Settings: Other

ds_content.field_header_image

Emergency Settings

Layouts

Layouts

Example Without

Example with

Using Layouts

Manage Display

Switching Layouts

Creating Layouts

<theme>.layouts.yml

 

<template>.html.twig

<theme>.layouts.yml

dz_1col_stacked:
  label: 1 Col - Stacked
  category: Dazzle
  class: '\Drupal\ds\Plugin\DsLayout'
  type: partial
  template: templates/nodes/dz-1col-stacked
  regions:
    ds_header:
      label: Header
    ds_content:
      label: Content
    ds_footer:
      label: Footer

<template>.html.twig

<{{ ds_content_wrapper }}{{ attributes.addClass('dz-1col-stacked', 'clearfix') }}>
  {{ title_suffix.contextual_links }}
  {% if ds_header %}
    <div class="header-wrapper" >
      {{ ds_header }}
    </div>
  {% endif %}
  {% if ds_content %}
    <div class="content-wrapper">
      {{ ds_content }}
    </div>
  {% endif %}
  {% if ds_footer %}
    <div class="footer-wrapper">
      {{ ds_footer }}
    </div>
  {% endif %}
</{{ ds_content_wrapper }}>

Result

DS Fields

Adding Custom Fields

Default Field settings

Block Field settings

Token Field Settings

DS Classes

Defining Classes

Using Classes

Custom Wrappers

DS Field Templates

DSFT Types

DSFT Types: Minimal

DSFT Types: Reset

DSFT Types: Expert

Configuring
Paragraphs

Parts

  1. Creating Paragraphs
  2. Adding Paragraphs
  3. Something Cool

 

Creating Paragraphs

Creating Paragraphs

Adding Fields

Adding Fields

Adding Paragraphs

Adding Paragraphs

Adding Paragraphs

Manage Form Display

Manage Display

Nesting

Bringing it all together

Now what?

+

Let's build some

cool stuff!

Reusing Paragraphs

Two Ways

  • Manually
  • Modules

Manually

​drush cex sync

 

 

 

 

 

 

 

Now copy/paste!

Module

Module

dazzle_paragraphs.info.yml

Module

dazzle_paragraphs.module

Module

/config

 

/config/install

 

/config/optional

Module

/config/install

 

  • core.base_field_override.paragraph.text.changed.yml
  • core.base_field_override.paragraph.text.created.yml
  • core.base_field_override.paragraph.text.uid.yml
  • core.entity_view_display.paragraph.text.default.yml
  • field.field.paragraph.text.field_body.yml
  • field.storage.paragraph.field_body.yml
  • paragraphs.paragraphs_type.text.yml
  • image.style.inline_page_image.yml

Module

/config/install

 

  • language.content_settings.paragraph.text.yml

Known issues

Paragraph Translations

Questions?

Thanks for listening!

And a big thank you to the awesome organisation of DrupalCamp Ghent!

Made with Slides.com