Exploring Drupal 8 – A little about us. – Let's talk Drupal...



Exploring Drupal 8 – A little about us. – Let's talk Drupal...

2 0


drupal8-training-day

Drupal 8 Training Day Curriculum

On Github nickgs / drupal8-training-day

Exploring Drupal 8

Long Island
Training Day

Nick Selvaggio | Rich von Rauchhaupt | Mai Irie

A little about us.

Hi! I'm Nick. I'm a Managing Partner @

Hi! I'm Rich. I'm a Web Platform Strategist & Architect @

Hi! I'm Mai. I'm a senior developer @

About LIDUG

Join the local community!

  • We meet every 3rd Wedsnday of the month @ LaunchPad Huntington

Try Drupal

TryDrupal8.com

Our podcast series: Talking Drupal Podcast

  • Try Drupal platform
  • About the podcast: http://www.talkingdrupal.com/

A little about you.

  • How many have experience with Drupal 7? 6?
  • From other environments? Ruby, Python, .NET
  • Who is excited about Drupal 8?

Play Along!

StackStarter.io/spin Spin Code: #trainingday
  • We will be going through alot of content!
  • A spin has been configured for your enjoyment!

Let's talk Drupal...

  • Talk a bit about the history of Drupal.
  • Initial release 2001

What is Drupal?

  • Modular CMS
  • More then a CMS.

Where have we come from?

Our many stages of evolution
  • 8 Major versions

Where are we going?

A revolution is happening!

Who uses Drupal?

Memorial Sloan Kettering Cancer Center (MSK)

One of the largest cancer centers in the United States, launched the new mskcc.org in May. It chose Drupal 8, even when the software was still in its beta phase, to help extend the reach of its "More Science. Less Fear" campaign.

CH2M

CH2M is a global corporation that works to keep governments, infrastructure, and environments sustainable. It uses Drupal 8 to present and prove its capabilities.

Many, Many, Many More

drupal.org/case-studies/featured/all/drupal-8.x

Lets step back...

Lets talk about the C in CMS

  • Lay the ground work to introduce core terminology

Content First

  • Think about our content first.
  • Decontruct what the content we are wanting to manage in order to structure it.

Structuring our content

  • Unstuctured vs Structured Content
  • Reusing content in different channels

What makes Drupal unique?

  • Structured Content

Some terminology

  • Unstuctured vs Structured Content
  • Reusing content in different channels

Entities

Nodes
Taxonomy
Users
Comments
...
  • You are define your own.
  • Growing number of CORE entities (ex. Blocks)

Fields

Text
Numbers
Select Lists
...
  • You are define your own.
  • Growing number of CORE entities (ex. Tel, Email)

Fields can be "bundled" with Entities

Nodes -> Content Types
Taxonomy -> Vocabularies
  • "Fieldable" entities

Views

Define Lists of Content
Define how to output the given list
  • Visual SQL builder

Modules

Finding Modules
When to bring in a module

Themes

Finding Themes
Base themes

Regions

Blocks

Lets dive in!

  • Dive into the Drupal administrative interface

Under the hood

We can do alot with just core. Let's see how we can extend.

File Structure

  • Where do modules live?
  • Where do themes live?

Settings.php and friends

  • services.yml

Make our lives easier with Drush

  • How many are confortable on the command line?
  • Download the Examples module

What about Drupal Console?

  • Show some of the commands available.

Ok are you ready to go deeper?

Stucture of a module

/modules/custom/hello/hello.info.yml

name: Hello
description: A friendly Drupal 8 module
type: module
core: 8.x

Modules now live in the /modules directory

We don't need a .module file anymore!

Lets make a Page...

Without hook_menu!

  • The Synfony Routing component is used for defining our routes
/modules/custom/hello/src/Controller/HelloController.php
/**
 * Our first Drupal 8 controller.
 */
namespace Drupal\hello\Controller;

use Drupal\Core\Controller\ControllerBase;

class HelloController extends ControllerBase {
  public function sayHi() {

    return array(
        '#markup'=>"Why hello Drupal 8",
      );
  }
}

/modules/custom/hello/hello.routing.yml

              hello.sayHi:
  path: '/hello'
  defaults:
    _controller: '\Drupal\hello\Controller\HelloController::sayHi'
  requirements:
    _permission: 'access content'
            

What about Forms?

Very similar pattern!

/modules/custom/hello/src/Form/HelloRequestForm.php

              /**
 * @file
 * Contains \Drupal\hello\Form\HelloRequestForm.
 */

namespace Drupal\hello\Form;

use Drupal\Core\Form\FormBase;
use Drupal\Core\Form\FormStateInterface;

class HelloRequestForm extends FormBase {
  /**
   * {@inheritdoc}.
   */
  public function getFormId() {
    return 'hello_request';
  }

  /**
   * {@inheritdoc}.
   */
  public function buildForm(array $form, FormStateInterface $form_state) {
    $form['phone_number'] = array(
      '#type' => 'tel',
      '#title' => $this->t('Your phone number')
    );
    $form['actions']['#type'] = 'actions';
    $form['actions']['submit'] = array(
      '#type' => 'submit',
      '#value' => $this->t('Give me a call'),
      '#button_type' => 'primary',
    );
    return $form;
  }

  /**
   * {@inheritdoc}
   */
  public function validateForm(array &$form, FormStateInterface $form_state) {
    if (strlen($form_state->getValue('phone_number')) < 3) {
      $form_state->setErrorByName('phone_number', $this->t('The phone number is too short. Please enter a full phone number.'));
    }
  }

  /**
   * {@inheritdoc}
   */
  public function submitForm(array &$form, FormStateInterface $form_state) {
    drupal_set_message($this->t('Your phone number is @number', array('@number' => $form_state->getValue('phone_number'))));
  }
}
            

/modules/custom/hello/hello.routing.yml

              hello.requestHi:
  path: '/hello/request'
  defaults:
    _form: '\Drupal\hello\Form\HelloRequestForm'
  requirements:
    _permission: 'access content'
            

Lets make a Block!

Without hook_block_info and hook_block_view!

/modules/custom/hello/src/Plugin/Block/HelloBlock.php

              namespace Drupal\hello\Plugin\Block;

use Drupal\Core\Block\BlockBase;

/**
 * Provides a 'Hello' block.
 *
 * @Block(
 *   id = "hello_block",
 *   admin_label = @Translation("Hello block"),
 * )
 */
class HelloBlock extends BlockBase {
  public function build() {
    return array(
      '#markup' => $this->t("This is a an awesome block!"),
    );
  }
}
            

How about themes?

Similar strucuture to modules.

Let's download some, and explore

  • Bootstrap, Foundation, Neato

Ok, we are experts. Lets build!

Let's build a site together, your client is a large educational institution and they require a small departmental site that will enable the following set of functionality

Manage users in two different roles:

  • Staff
  • Student

Ability to create and share events on an event page.

Events can be any of the various different types:

  • Student Events
  • Faculty Events
  • Community Events

Events are accessible by anyone.

Today we covered:

  • Provided an overview of our active local community
  • Learned about the history of Drupal
  • What makes Drupal a unique and powerful CMS.
  • Reviewed the core concepts of a Drupal site
  • Took a tour of the Drupal 8 interface
  • Dove deeper into the internals of Drupal 8
  • Built a basic site using some of the topics covered

Support Drupal & community events like this

The Drupal Association is dedicated to helping the open-source Drupal CMS project flourish. Learn more about what we do: We help the Drupal community with funding, infrastructure, education, promotion, distribution and online collaboration at Drupal.org. Funds to support these programs, and the Association staff come from memberships, supporting partners, sponsorships, donations, and DrupalCon events. Join us to help ensure a creative and exciting future for Drupal!

Drupal Association Member Benefits

  • Listed in public directories
  • Receive discounts from DA partners like O'Reilly, Drupal Watchdog, and BuildAModule
  • Membership Badge on your Drupal user profile
  • Receive the latest news on Drupal Association projects.

Thank you!

Please share your feedback! https://www.surveymonkey.com/r/XWGNNPP

Exploring Drupal 8 Long Island Training Day Nick Selvaggio | Rich von Rauchhaupt | Mai Irie