BUILDING FLEXIBLE PAGE-LAYOUTS WITH DS & PARAGRAPHS

Pieter Mathys - @mathysp - dazzle
First of all


No need to take pictures!
Just follow along here:
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
Download from:
https://www.drupal.org/project/drupal
Or Drush:
drush dl drupal-8 --select
Great Guides:
- https://www.chenhuijing.com/blog/drupal-101-getting-started-with-d8/#👾
- 27 Questions (and Answers) from My First Drupal 8 Site Build https://www.drupal.org/node/2360331
Install DS


Install Paragraphs
Download from:
https://www.drupal.org/project/paragraphs
$ drush dl paragraphs
Enable:
admin/modules
$ drush en paragraphs


Configuring
Display Suite


Parts
- Settings
- Layout
- DS Fields
- DS Classes
- Layout Wrappers
- 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


- Creating Paragraphs
- Adding Paragraphs
- 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


Issue Discussion
https://www.drupal.org/node/2461695
Patch by @trobert_
https://www.drupal.org/files/issues/paragraphs_localised-2461695.patch
Questions?


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

BUILDING FLEXIBLE PAGE-LAYOUTS WITH DS & PARAGRAPHS
By Pieter Mathys
BUILDING FLEXIBLE PAGE-LAYOUTS WITH DS & PARAGRAPHS
A Short presentation that will get you up & running with Drupal 8, Display Suite and Paragraphs
- 2,063