Hands On With Drupal 8

8.x Internals for site builders

Who is This Person?

Tess Flynn


@socketwench

"That's wench, not wrench"

Module Co-maintainer For

Flag

Flag Friend

Examples

Drupal Developer With

(We're hiring!)

Follow Along

http://socketwench.github.io/handsOnD8SiteBuilder

How Different is D8?

Not That Different!

(If you're a site builder)

Many of the Concepts are the Same

Users and Permissions

Structuring Content

Modules

And it's Even Easier!

Views in core

Better, out-of-the-box i18n Support

(Fewer modules to install, yay!)

Where it's Different

Writing modules

Writing themes

Upgrading core and modules

Deploying Configuration

Getting a Development Environment

Many Options

Local installation

Virtualization

Hosting Providers

Local Installation

Install a webserver on your laptop

Virtualized Environments

Virtualized Environments

Virtualization Providers

Virtualization Providers

Virtualization Providers

Hosting Providers

And many others...

Installation

New Requirements

New Requirements

New Requirements

New Requirements

New Requirements

New Requirements

New Requirements

Download Drupal

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

Installing Dev Desktop

https://www.acquia.com/downloads

Using Simplytest.me

Using Simplytest.me

Using Pantheon

Free for 3 dev sites

http://getpantheon.com/d8

The Install Wizard

Prettier & handles languages better

Asks similar questions as in 7.x

Hosting providers may do this for you!

Using the Install Wizard

Using the Install Wizard

Using the Install Wizard

Using the Install Wizard

Using the Install Wizard

Using the Install Wizard

Using the Install Wizard

Your Turn!

Pair up!

If neither of you have a web server installed, choose a hosting provider

Install the latest Drupal 8 Beta

Time: 15 minutes

Structuring Content

Adding Node Types

Nothing Looks that Different

Yep, we need to go deeper

Features Module

Saves configuration to code

Works okay in Drupal 7

A Tale of Two Entity Kinds

Configuration Entities

Administrator-built structures

Configuration Entities

Administrator-built structures

Configuration Entities

Administrator-built structures

Configuration Entities

Administrator-built structures

Content Entities

User created & instantiated objects

Content Entities

User created & instantiated objects

Content Entities

User created & instantiated objects

Content Entities

User created & instantiated objects

Managing Configuration

Config Management UI

Admin > Development > Configuration Management

Single Export

Full Export

Creates a *.tar.gz of all site configurations

Easiest way to get export filnames

Your Turn

Create a new content (node) type

Export your new content type

Make changes to your content type

Export your content type again, what changed?

Time: 10 minutes

Fields

Nodes and Fields

Nodes and Fields

Nodes and Fields

Nodes and Fields

Fields and the Database

Fields and the Database

Fields and the Database

Fields and the Database

Fields and the Database

Field names no longer global!

Tied to their owning entity type

entity_type/field_name

Sharing Fields in 8.x

No longer sharable between entity types (node, user)

Sharable between bundles (article, story)

New Field Types

Comments

Entity Reference

Link

Date

Email

Telephone

Fields are Plugins!

Not a module, not a Wordpress "Plugin"

Programming pattern -- Object-oriented info hook

Other Plugins

And many others...

Fields are also Config Entities

Exportable to *.yml

Migrated from site to site

Your Turn!

Create a new field for your content type

Re-export your content type, did anything change?

Explore the export interface, find two places to export your field

Time: 10 minutes

Users

Managing Users

Admin > People

Superuser account created on install

No real changes here

Account Settings

Admin > Configure > People > Account Settings

Welcome messages, email prefs, field management

Pretty much as you expect

Account Form Display

New in 8

Control order of fields on user edit form

Exporting Account Settings

Stored as simple config

Your Turn

Create a new user

Create a custom field for the user, export it

Answer: Are users content or config?

Answer: How many exports are needed to capture account customizations?

Time: 7 Minutes

Roles and Permissions

Where do Permissions Come From?

And is it still the same?

flag.permissions.yml


administer flags:
 title: 'Administer Flags'
 decription: 'Define and manage Flags and Flag settings.'
 restrict access: TRUE

permission_callbacks:
 - Drupal\flag\FlagPermissions::permissions
                        

Managing Roles

Admin > People > "Roles" tab

Roles are now config entities

No UI changes from 7.x

Managing Permissions

Admin > People > "Permissions" tab

Set checkbox = Grants permission

Clear checkbox = Doesn't grant, doesn't deny

Default Roles

Default Roles

Default Roles

Default Roles

Default Roles

So What Are Roles?

Exportable, Migratable

Your Turn!

Create a "content editor" role

Assign it node creation/editing rights

Answer: How do you export permissions?

Time: 8 minutes

Views

Now in core!

No more waiting to build real sites

Views UI

Largely unchanged from 7.x

No More Overrides!

Core's own UI uses views

Makes modifying core pages easy and safe

Views are Config Entities

Exportable, migratable

Uses core's main export UI, not Views UI

Your Turn!

Create demo content using your new content type

Beginners: Create a new view for your content type

Modify one of core's default views

Export the view configuration

Time: 10 minutes

Modules

Yes! They Still Exist!

You'll need less of them for a functional site

Vastly different programming makes porting difficult

Installation and config management is different

Installing Modules

No built-in FTP downloader

Use drush 7.x or download manually

Please use version control

No Neally, Use Version Control

Many hosting providers have it baked in

No Neally, Use Version Control

Many hosting providers have it baked in

No Neally, Use Version Control

Many hosting providers have it baked in

Where do Contrib Modules Go?

Where do Contrib Modules Go?

Where do Contrib Modules Go?

Where do Contrib Modules Go?

That's...Confusing

Yeah, it's the opposite of 7.x

core/ directory makes upgrading easier

There is no sites/all directory

Installing on Simplytest.me

Not really possible

Create new instance, select module to install

Installing on Pantheon

Click "SFTP" in your dashboard

Use your favorite SFTP client

Contrib Modules and Configuration

Any properly designed module will have exportable config

Saving directly to database tables is strongly discouraged

Default Module Configuration

Default Module Configuration

Default Module Configuration

Default Config YML

Often exported from Drupal itself

Makes creating "features" modules easy!

Flag Module for 8.x

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

Download the 8.x-4.x-dev version

Your Turn!

Download and install Flag module

Create a new Flag: Admin > Structure > Flags

Export your new Flag

Time: 15 minutes

Themes

Themes are a lot like modules

Install manually or with drush

Where do Themes Go?

Where do Themes Go?

Okay, Just Like Modules

It's the opposite of 7.x, but...

...it's much easier to find.

So What's Different?

Well, lots, actually.

Twig In Core

Replaces PHPtemplate

Common outside of Drupal

Fast; compiles down to PHP

Where Can I Learn More About Twig?

http://twig.sensiolabs.org/documentation

https://www.drupal.org/theme-guide/8

Other Front-End Improvements

Latest JQuery and Backbone.js

Accessible and responsive

CMI

Module Provided Configuration

No Features required!

Basic Feature Module

Basic *.info.yml


                            name: My Blog
                            type: module
                            description: My Awesome Blog Feature
                            core: 8.x
                            package: Features
                            dependencies:
                             - link
                        

*.module File

Required, even if empty

Generating Modules

drupal generate:module

Perform a Full Export

Filenames are significant!

Much easier to build, then export

Finding Files

Node type ID, field ID, etc.

Start with the biggest piece, and look for dependencies

Dependencies Export Entry


                            uuid: 88ba4ba6-2694-4154-9048-72fb7fdb4e4c
                            langcode: en
                            status: true
                            dependencies:
                                config:
                                    - field.storage.node.field_see_also
                                    - node.type.blog
                                module:
                                    - link
                            id: node.blog.field_see_also
                            field_name: field_see_also
                            entity_type: node
                            bundle: blog
                            label: 'See also'
                        

Prepairing Export Files

Each configuration assigned a UUID

Remove if you need unique IDs between dev/test/prod

node.type.blog.yml


                            uuid: cf4c20f8-213a-46fc-8a06-6f1036203231
                            langcode: en
                            status: true
                            dependencies:
                            module:
                             - menu_ui
                            third_party_settings:
                            menu_ui:
                            available_menus:
                             - main
                            parent: 'main:'
                            name: Blog
                            type: blog
                            description: ''
                            help: ''
                            new_revision: false
                            preview_mode: 1
                            display_submitted: true
                        

Failing Meet Dependencies

Will halt module enabling

Error message will identify missing configuration

Your Turn!

Perform a full export

Build a new feature module based on your custom content type

Delete your custom configuration

Upload and enable your custom module

Time: 20 minutes

Come Sprint with Us!

Learn and contribute to Drupal Core

Mentors will help you setup and find issues

9am - 4pm on the FTC Campus

Thank you!

 

@socketwench

 

http://socketwench.github.io/handsOnD8SiteBuilder