SlideShare ist ein Scribd-Unternehmen logo
1 von 87
Downloaden Sie, um offline zu lesen
Drupal 8 frontend
development
for dummies
Exausted?
Almost done…*
*only 2 more hours
Andrea Panisson… Who?
I work in
as frontend developer.
I care UI, IA, Drupal Theming and I care about
clients.
What’s new in Drupal 8 for
themers
D7
 PHPTemplate
 Theme functions +
template files
 Structured markup in core
and ‘hardcoded’ classes
 HTML
D8
 Twig
 Template files
 Minimal markup and
classes in core
 HTML5 in core
Twig?
Twig is a modern PHP-based compiled
templating language.
What's new in Drupal 8 for themers
&
the Twig template engine.
 PHPtemplate
 theme functions
 markup in core
Farewell to
Welcome to
 No more markup in core
 All through template files
 HTML5
 Twig
All through template files
Twig: what & why
What?
 A template engine for PHP
Why?
 Twig was created by people behind Synfony2
 Synfony2 was integrated in Drupal 8 core
Twig was chosen because it was the best choice after
comparing various templating languages.
"… We don't have Twig because we have Symfony. It's
more that, we have Twig because it's AWESOME"
- Scott Reeves, @Cottser
“Twig…because it's AWESOME”
But why abandoning
PHPtemplate?
1. Syntax
2. Inconsistency
3. Complexity
4. Redundancy
5. Security
“Twig…because it's
AWESOME”
Mixed data types in template files
#1. D8 syntax: TWIG
All variables are
printed the same way
#2. Inconsistency
D7different ways to do the same thing:
 Template files or Theme functions.
 Theme functions or render arrays
D8
 Only template files
 Only render arrays
#3. D7: complexity
Drupal 7 was funny!
#3. D8: less complexity
D8 is boring!
#4. D7: redundancy
There's a lot of duplicated code in themes, we often have multiple
files with the same lines of code.
#4. D8: less redundancy
No need to repeat code between templates, we can extend
templates with Twig.
#5. Security
D7
In a PHPTemplate file you can print all sort of unsanitized data,
even delete a table from your DB.
D8
In Twig this is not possible, Twig's autoescape feature is enabled by
default.
TWIG: no more conflict
backend - frontend
They are now separated!
TWIG: easy to learn!
Twig: syntax
Twig: no more var drilling
Drupal 7 and PHPtemplate
Drupal 8 and Twig
Twig: functions (filters)
Twig: |Functions (filters)
Twig: translate
Twig: controls
Twig: loops
Twig: setting vars
Twig: blocks
page.html.twig
Twig: blocks
page--front.html.twig
Twig: includes
Template files are reusable, thanks to Twig includes
http://twig.sensiolabs.org/doc/tags/include.html
{% include “footer.html.twig" %}
Or using namespaces:
{% include “@my_theme/partials/footer.html.twig" %}
Twig coding standard (T.c.s.)
 Generic Twig coding standards:
http://twig.sensiolabs.org/doc/coding_standards.html
 Twig in Drupal coding standards:
http://drupal.org/node/1823416
T.c.s. - HTML attributes
In Drupal core, we will print only the class attribute specially, all
the others will be printed as part of {{ attributes }}.
The reason for this is that it needs to be very easy for front end
developers to be able to add a class, anywhere
T.c.s. - Whitespaces
T.c.s. - Comments
 Singleline:
 Multiline
Twig docs
twig.sensiolabs.org
And so, Twig advantages:
 a clear separation between the logic and the
view
 no more PHP code inside your template files
 it's not only used in Drupal core, so it's not a
Drupaly-thing
and Twig disadvantages:
thing to learn
YAML
Yet Another Markup Language*
* YAML Ain't Markup Language
"YAML is a human friendly data serialization standard for all
programming languages."
-yaml.org
Pronounced “yamel” (rhymes with camel).
YAML
sites/default/services.yml
Why YAML?
 YAML is both human editable and machine readable.
 .yml files are not Drupal specific like .info files.
And why not XML?
 XML would require a Drupal specific schema.
Or JSON?
 JSON doesn't allow comments.
 Non-ASCII characters require escaping in JSON.
Theme folder structure
The directory structure
of Drupal 8 has
changed!
https://www.drupal.org/node/2349803
Location of themes
/themes
For themes that should be available to all sites.
/sites/{site}/themes
For themes that should be available on a specific site (on a
multisite installation).
Location of themes
Theme folder structure
Most common theme files
*.info.yml
*.libraries.yml
*.breakpoints.yml
*.theme
Theme folder structure: https://www.drupal.org/node/2349803
*.info.yml (ex *.info)
 A theme must contain an .info.yml file to define the theme.
 Among other things the .info.yml files defines meta data, style
sheets, and block regions.
 This is the only required file in the theme.
*.libraries.yml
 The .libraries.yml file is used to define JavaScript and CSS
libraries that can be loaded by the theme.
 A library as a collection of CSS and JS.
*.libraries.yml
Libraries are called in the info file:
and defined in the *.libraries.yml file:
*.breakpoints.yml
 Breakpoints define where a responsive design needs to
change in order to respond to different devices.
 Breakpoints are defined in a .breakpoints.yml file
*.theme (ex template.php)
 The .theme file is a PHP file that contains all the conditional
logic and data (pre)processing of the output.
The theme layer
The new theme layer
Bye bye theming functions!
ALL GONE: All of the theme() functions have been
converted to Twig templates.
New theme hooks
 Theme suggestions
hook_theme_suggestions()
hook_theme_suggestions_HOOK()
 Theme suggestions alter:
hook_theme_suggestions_alter(),
hook_theme_suggestions_HOOK_alter()
 Theme preprocess:
THEME_preprocess(&$variables, $hook),
THEME_preprocess_HOOK(&$variables)
https://api.drupal.org/api/drupal/core!lib!Drupal!Core!Render!theme.api.php/group/themeable/8
Removed process hooks
 The process layer (hook_process and
hook_process_HOOK) is gone!
The preprocess layer
 The preprocess layer still exists, but it's used for a different
purpose.
 In Drupal 8, the preprocess layer should not be used to add css
classes.
 This should be done in the template files.
https://www.drupal.org/node/2325067
Drupal 8 core themes
Drupal 8 core themes
 bartik
 seven
 stark
 classy
 stable
Backwards compatibility
throughout the Drupal 8 cycle
Default admin theme
Default theme
Drupal core markup test theme
Drupal 8 core themes: bartik
A flexible,
recolorable
theme with
many regions
and a
responsive,
mobile-first
layout.
The default
theme in
Drupal 8.
Drupal 8 core themes: seven
The default
administration
theme for Drupal
8.
Now fully
responsive.
Drupal 8 core themes: stark
An intentionally plain
theme with almost
no styling to
demonstrate default
Drupal’s HTML and
CSS.
Stark only outputs
html and css from
modules.
 Add no CSS
 Add no templates
Drupal 8 core themes: stable
The Stable theme will function as a backwards
compatibility layer for Drupal 8's core markup, CSS and JS.
A theme will always use Stable as the base theme unless
you set
in your theme .info.yml file.
Drupal 8 core themes: classy
The classes from core have been moved into the classy
base theme.
Now all template files in core are “classless”.
Is the base theme that Seven and Bartik will extend from.
https://www.lullabot.com/articles/a-tale-of-two-base-themes-in-drupal-8-core
@mortendk
Drupal 8 core templates
core/modules/system/templates
New CSS architecture
SMACSS
Scalable and Modular Architecture for CSS
• Base
• Layout
• Component
• State
• Theme
BEM
Block Element Modifier naming convention
.block__element--modifier
Development tools!
Development tools
Before start with theme development (Drupal
development) let’s get some tools:
Drush: http://www.drush.org
Drupal Console: http://drupalconsole.com
Devel module (& Kint): http://drupal.org/project/devel
Installing composer…
curl -sS https://getcomposer.org/installer | php
mv composer.phar /usr/local/bin/composer
https://getcomposer.org/doc/00-intro.md#globally
Install Drupal console / drush
Edit (global) composer.json and then run composer update
Install Drupal console / drush
composer global require drush/drush:dev-master
composer global require drupal/console:@stable
Remember to add the binaries composer directory to your
path, i.e.
$ echo "PATH=$PATH:~/.composer/vendor/bin" >> ~/.bash_profile
Most useful drush commands:
 Clear cache
drush cr
 Download / enable a module
drush en module_name
 HELP ME!
drush help
Most useful console
commands:
 Generate a theme:
console generate:theme
 More to come... *
* Please, RTFM!
Enable debugging:
the manual way
 Locate services.yml file (sites/default/services.yml)
 If services.yml does not yet exist copy
default.services.yml and rename it to services.yml
 Edit the services.yml file and enable one or more of the
debugging options
 Rebuild cache
Enable debugging:
the manual way (continue)
parameters:
twig.config:
# Twig debugging:
debug: true
# Twig auto-reload:
auto_reload: true
# Twig cache:
cache: true
Enable debugging:
Drupal Console
https://www.drupal.org/node/1903374
console site:mode dev
Disable render cache
Drupal caches any rendering it performs for
blocks and entities, to speed up subsequent
page loads.
This means that changes to Twig templates for
these will not take effect immediately.
Disable render cache
 add the following lines at the bottom of settings.php
if (file_exists(__DIR__ . '/settings.local.php')) {
include __DIR__ . '/settings.local.php';
}
 copy sites/example.settings.local.php to
sites/default/settings.local.php
 clear the Drupal caches.
Disable render cache
In settings.local.php:
 disable the render cache (this includes the page cache).
$settings['cache']['bins']['render'] = 'cache.backend.null';
 disable Dynamic Page Cache.
$settings['cache']['bins']['dynamic_page_cache'] = 'cache.backend.null';
Devel and Kint
drush dl devel
Kint, the new Krumo
http://raveren.github.io/kint/
Twig: compiled in PHP template
Twig template engine takes the template file and
converts it into a 'compiled' PHP template in
sites/default/files/php/twig/*
(drush cr clean this folder too)
Resources
 Twig official: http://twig.sensiolabs.org/
 Theming Drupal 8: https://drupal.org/theme-guide/8
 The Drupal 8 Theming guide: http://d8.sqndr.com/
More articles
 Drupal 8 Theming Fundamentals, Part 1
 Drupal 8 Theming Fundamentals, Part 2
 A Tale of Two Base Themes in Drupal 8 core
Drupal 8 - Corso frontend development

Weitere ähnliche Inhalte

Was ist angesagt?

Drupal 8 Configuration Management
Drupal 8 Configuration ManagementDrupal 8 Configuration Management
Drupal 8 Configuration ManagementPhilip Norton
 
Drupal 8 CMI on a Managed Workflow
Drupal 8 CMI on a Managed WorkflowDrupal 8 CMI on a Managed Workflow
Drupal 8 CMI on a Managed WorkflowPantheon
 
Configuration Management in Drupal 8: A preview (DrupalDays Milano 2014)
Configuration Management in Drupal 8: A preview (DrupalDays Milano 2014)Configuration Management in Drupal 8: A preview (DrupalDays Milano 2014)
Configuration Management in Drupal 8: A preview (DrupalDays Milano 2014)Nuvole
 
Development Workflow Tools for Open-Source PHP Libraries
Development Workflow Tools for Open-Source PHP LibrariesDevelopment Workflow Tools for Open-Source PHP Libraries
Development Workflow Tools for Open-Source PHP LibrariesPantheon
 
Build Automation of PHP Applications
Build Automation of PHP ApplicationsBuild Automation of PHP Applications
Build Automation of PHP ApplicationsPavan Kumar N
 
Introduction to Drupal (7) Theming
Introduction to Drupal (7) ThemingIntroduction to Drupal (7) Theming
Introduction to Drupal (7) ThemingRobert Carr
 
CakePHP 2.0 - It'll rock your world
CakePHP 2.0 - It'll rock your worldCakePHP 2.0 - It'll rock your world
CakePHP 2.0 - It'll rock your worldGraham Weldon
 
Drupal Backend Performance and Scalability
Drupal Backend Performance and ScalabilityDrupal Backend Performance and Scalability
Drupal Backend Performance and ScalabilityAshok Modi
 
Building a Dynamic Website Using Django
Building a Dynamic Website Using DjangoBuilding a Dynamic Website Using Django
Building a Dynamic Website Using DjangoNathan Eror
 
Best Practices for Front-End Django Developers
Best Practices for Front-End Django DevelopersBest Practices for Front-End Django Developers
Best Practices for Front-End Django DevelopersChristine Cheung
 
Django, What is it, Why is it cool?
Django, What is it, Why is it cool?Django, What is it, Why is it cool?
Django, What is it, Why is it cool?Tom Brander
 
[drupalday2017] - REST in pieces
[drupalday2017] - REST in pieces[drupalday2017] - REST in pieces
[drupalday2017] - REST in piecesDrupalDay
 

Was ist angesagt? (20)

Drupal 8 Configuration Management
Drupal 8 Configuration ManagementDrupal 8 Configuration Management
Drupal 8 Configuration Management
 
Drupal 8 CMI on a Managed Workflow
Drupal 8 CMI on a Managed WorkflowDrupal 8 CMI on a Managed Workflow
Drupal 8 CMI on a Managed Workflow
 
Configuration Management in Drupal 8: A preview (DrupalDays Milano 2014)
Configuration Management in Drupal 8: A preview (DrupalDays Milano 2014)Configuration Management in Drupal 8: A preview (DrupalDays Milano 2014)
Configuration Management in Drupal 8: A preview (DrupalDays Milano 2014)
 
Drupal
DrupalDrupal
Drupal
 
YouDrup_in_Drupal
YouDrup_in_DrupalYouDrup_in_Drupal
YouDrup_in_Drupal
 
Development Workflow Tools for Open-Source PHP Libraries
Development Workflow Tools for Open-Source PHP LibrariesDevelopment Workflow Tools for Open-Source PHP Libraries
Development Workflow Tools for Open-Source PHP Libraries
 
backend
backendbackend
backend
 
Build Automation of PHP Applications
Build Automation of PHP ApplicationsBuild Automation of PHP Applications
Build Automation of PHP Applications
 
Introduction to Drupal (7) Theming
Introduction to Drupal (7) ThemingIntroduction to Drupal (7) Theming
Introduction to Drupal (7) Theming
 
Installing AtoM with Ansible
Installing AtoM with AnsibleInstalling AtoM with Ansible
Installing AtoM with Ansible
 
CakePHP 2.0 - It'll rock your world
CakePHP 2.0 - It'll rock your worldCakePHP 2.0 - It'll rock your world
CakePHP 2.0 - It'll rock your world
 
Drupal Backend Performance and Scalability
Drupal Backend Performance and ScalabilityDrupal Backend Performance and Scalability
Drupal Backend Performance and Scalability
 
Building a Dynamic Website Using Django
Building a Dynamic Website Using DjangoBuilding a Dynamic Website Using Django
Building a Dynamic Website Using Django
 
Django in the Real World
Django in the Real WorldDjango in the Real World
Django in the Real World
 
Best Practices for Front-End Django Developers
Best Practices for Front-End Django DevelopersBest Practices for Front-End Django Developers
Best Practices for Front-End Django Developers
 
Django
DjangoDjango
Django
 
Django, What is it, Why is it cool?
Django, What is it, Why is it cool?Django, What is it, Why is it cool?
Django, What is it, Why is it cool?
 
Django by rj
Django by rjDjango by rj
Django by rj
 
Ant User Guide
Ant User GuideAnt User Guide
Ant User Guide
 
[drupalday2017] - REST in pieces
[drupalday2017] - REST in pieces[drupalday2017] - REST in pieces
[drupalday2017] - REST in pieces
 

Ähnlich wie Drupal 8 - Corso frontend development

Drupal 8: frontend development
Drupal 8: frontend developmentDrupal 8: frontend development
Drupal 8: frontend developmentsparkfabrik
 
Building a Custom Theme in Drupal 8
Building a Custom Theme in Drupal 8Building a Custom Theme in Drupal 8
Building a Custom Theme in Drupal 8Anne Tomasevich
 
Drupal 8 introduction to theming
Drupal 8  introduction to themingDrupal 8  introduction to theming
Drupal 8 introduction to themingBrahampal Singh
 
Drupal7 themeing changes and inheritence
Drupal7 themeing changes and inheritenceDrupal7 themeing changes and inheritence
Drupal7 themeing changes and inheritenceAimee Maree Forsstrom
 
Converting (X)HTML/CSS template to Drupal 7 Theme
Converting (X)HTML/CSS template to Drupal 7 ThemeConverting (X)HTML/CSS template to Drupal 7 Theme
Converting (X)HTML/CSS template to Drupal 7 ThemeAdolfo Nasol
 
SynapseIndia drupal presentation on drupal best practices
SynapseIndia drupal  presentation on drupal best practicesSynapseIndia drupal  presentation on drupal best practices
SynapseIndia drupal presentation on drupal best practicesSynapseindiappsdevelopment
 
Introduction To Drupal
Introduction To DrupalIntroduction To Drupal
Introduction To DrupalLauren Roth
 
Drupal Theming for Developers
Drupal Theming for DevelopersDrupal Theming for Developers
Drupal Theming for DevelopersIan Carnaghan
 
7 Theming in Drupal
7 Theming in Drupal7 Theming in Drupal
7 Theming in DrupalWingston
 
Twig in the wild august 2018 drupal govcon draft
Twig in the wild   august 2018 drupal govcon draftTwig in the wild   august 2018 drupal govcon draft
Twig in the wild august 2018 drupal govcon draftJeremyKoulish
 
Theming tips and tricks
Theming tips and tricksTheming tips and tricks
Theming tips and tricksaaroncouch
 
Learning PHP for Drupal Theming, DC Chicago 2009
Learning PHP for Drupal Theming, DC Chicago 2009Learning PHP for Drupal Theming, DC Chicago 2009
Learning PHP for Drupal Theming, DC Chicago 2009Emma Jane Hogbin Westby
 
Ready. Set. Drupal! An Intro to Drupal 8, Part 2
Ready. Set. Drupal! An Intro to Drupal 8, Part 2Ready. Set. Drupal! An Intro to Drupal 8, Part 2
Ready. Set. Drupal! An Intro to Drupal 8, Part 2Acquia
 
Twig for Drupal @ Frontendunited Amsterdam 2012
Twig for Drupal @ Frontendunited Amsterdam 2012Twig for Drupal @ Frontendunited Amsterdam 2012
Twig for Drupal @ Frontendunited Amsterdam 2012Rene Bakx
 
Drupal 8 - Core and API Changes
Drupal 8 - Core and API ChangesDrupal 8 - Core and API Changes
Drupal 8 - Core and API ChangesShabir Ahmad
 
Top 8 Improvements in Drupal 8
Top 8 Improvements in Drupal 8Top 8 Improvements in Drupal 8
Top 8 Improvements in Drupal 8Angela Byron
 

Ähnlich wie Drupal 8 - Corso frontend development (20)

Drupal 8: frontend development
Drupal 8: frontend developmentDrupal 8: frontend development
Drupal 8: frontend development
 
Building a Custom Theme in Drupal 8
Building a Custom Theme in Drupal 8Building a Custom Theme in Drupal 8
Building a Custom Theme in Drupal 8
 
Drupal 8 introduction to theming
Drupal 8  introduction to themingDrupal 8  introduction to theming
Drupal 8 introduction to theming
 
Drupal - Introduction to Drupal Creating Modules
Drupal - Introduction to Drupal Creating ModulesDrupal - Introduction to Drupal Creating Modules
Drupal - Introduction to Drupal Creating Modules
 
Drupal7 themeing changes and inheritence
Drupal7 themeing changes and inheritenceDrupal7 themeing changes and inheritence
Drupal7 themeing changes and inheritence
 
Converting (X)HTML/CSS template to Drupal 7 Theme
Converting (X)HTML/CSS template to Drupal 7 ThemeConverting (X)HTML/CSS template to Drupal 7 Theme
Converting (X)HTML/CSS template to Drupal 7 Theme
 
Designing with Drupal 8
Designing with Drupal 8Designing with Drupal 8
Designing with Drupal 8
 
SynapseIndia drupal presentation on drupal best practices
SynapseIndia drupal  presentation on drupal best practicesSynapseIndia drupal  presentation on drupal best practices
SynapseIndia drupal presentation on drupal best practices
 
Drupal
DrupalDrupal
Drupal
 
Introduction To Drupal
Introduction To DrupalIntroduction To Drupal
Introduction To Drupal
 
Drupal Theming for Developers
Drupal Theming for DevelopersDrupal Theming for Developers
Drupal Theming for Developers
 
7 Theming in Drupal
7 Theming in Drupal7 Theming in Drupal
7 Theming in Drupal
 
Twig in the wild august 2018 drupal govcon draft
Twig in the wild   august 2018 drupal govcon draftTwig in the wild   august 2018 drupal govcon draft
Twig in the wild august 2018 drupal govcon draft
 
Theming tips and tricks
Theming tips and tricksTheming tips and tricks
Theming tips and tricks
 
Learning PHP for Drupal Theming, DC Chicago 2009
Learning PHP for Drupal Theming, DC Chicago 2009Learning PHP for Drupal Theming, DC Chicago 2009
Learning PHP for Drupal Theming, DC Chicago 2009
 
Ready. Set. Drupal! An Intro to Drupal 8, Part 2
Ready. Set. Drupal! An Intro to Drupal 8, Part 2Ready. Set. Drupal! An Intro to Drupal 8, Part 2
Ready. Set. Drupal! An Intro to Drupal 8, Part 2
 
Twig for Drupal @ Frontendunited Amsterdam 2012
Twig for Drupal @ Frontendunited Amsterdam 2012Twig for Drupal @ Frontendunited Amsterdam 2012
Twig for Drupal @ Frontendunited Amsterdam 2012
 
Drupal 8 - Core and API Changes
Drupal 8 - Core and API ChangesDrupal 8 - Core and API Changes
Drupal 8 - Core and API Changes
 
Drupal theme development
Drupal theme developmentDrupal theme development
Drupal theme development
 
Top 8 Improvements in Drupal 8
Top 8 Improvements in Drupal 8Top 8 Improvements in Drupal 8
Top 8 Improvements in Drupal 8
 

Mehr von sparkfabrik

KCD Italy 2023 - Secure Software Supply chain for OCI Artifact on Kubernetes
KCD Italy 2023 - Secure Software Supply chain for OCI Artifact on KubernetesKCD Italy 2023 - Secure Software Supply chain for OCI Artifact on Kubernetes
KCD Italy 2023 - Secure Software Supply chain for OCI Artifact on Kubernetessparkfabrik
 
20231129 - Platform @ localhost 2023 - Application-driven infrastructure with...
20231129 - Platform @ localhost 2023 - Application-driven infrastructure with...20231129 - Platform @ localhost 2023 - Application-driven infrastructure with...
20231129 - Platform @ localhost 2023 - Application-driven infrastructure with...sparkfabrik
 
IAD 2023 - 22 Years of Agile and all I got is this lousy t-shirt
IAD 2023 - 22 Years of Agile and all I got is this lousy t-shirtIAD 2023 - 22 Years of Agile and all I got is this lousy t-shirt
IAD 2023 - 22 Years of Agile and all I got is this lousy t-shirtsparkfabrik
 
2023 - Drupalcon - How Drupal builds your pages
2023 - Drupalcon - How Drupal builds your pages2023 - Drupalcon - How Drupal builds your pages
2023 - Drupalcon - How Drupal builds your pagessparkfabrik
 
2023 - TAC23 - Agile HR - Racconti dal fronte
2023 - TAC23 - Agile HR - Racconti dal fronte2023 - TAC23 - Agile HR - Racconti dal fronte
2023 - TAC23 - Agile HR - Racconti dal frontesparkfabrik
 
CodeMotion 2023 - Deep dive nella supply chain della nostra infrastruttura cl...
CodeMotion 2023 - Deep dive nella supply chain della nostra infrastruttura cl...CodeMotion 2023 - Deep dive nella supply chain della nostra infrastruttura cl...
CodeMotion 2023 - Deep dive nella supply chain della nostra infrastruttura cl...sparkfabrik
 
What is the Secure Supply Chain and the Current State of the PHP Ecosystem
What is the Secure Supply Chain and the Current State of the PHP EcosystemWhat is the Secure Supply Chain and the Current State of the PHP Ecosystem
What is the Secure Supply Chain and the Current State of the PHP Ecosystemsparkfabrik
 
UX e Web sostenibile (UXday 2023).pdf
UX e Web sostenibile (UXday 2023).pdfUX e Web sostenibile (UXday 2023).pdf
UX e Web sostenibile (UXday 2023).pdfsparkfabrik
 
Drupal Dev Days Vienna 2023 - What is the secure software supply chain and th...
Drupal Dev Days Vienna 2023 - What is the secure software supply chain and th...Drupal Dev Days Vienna 2023 - What is the secure software supply chain and th...
Drupal Dev Days Vienna 2023 - What is the secure software supply chain and th...sparkfabrik
 
Deep dive nella supply chain della nostra infrastruttura cloud
Deep dive nella supply chain della nostra infrastruttura cloudDeep dive nella supply chain della nostra infrastruttura cloud
Deep dive nella supply chain della nostra infrastruttura cloudsparkfabrik
 
KCD Italy 2022 - Application driven infrastructure with Crossplane
KCD Italy 2022 - Application driven infrastructure with CrossplaneKCD Italy 2022 - Application driven infrastructure with Crossplane
KCD Italy 2022 - Application driven infrastructure with Crossplanesparkfabrik
 
Come Drupal costruisce le tue pagine
Come Drupal costruisce le tue pagineCome Drupal costruisce le tue pagine
Come Drupal costruisce le tue paginesparkfabrik
 
Drupal 10: un framework PHP di sviluppo Cloud Native moderno
Drupal 10: un framework PHP di sviluppo Cloud Native modernoDrupal 10: un framework PHP di sviluppo Cloud Native moderno
Drupal 10: un framework PHP di sviluppo Cloud Native modernosparkfabrik
 
Do you know what your Drupal is doing Observe it! (DrupalCon Prague 2022)
Do you know what your Drupal is doing Observe it! (DrupalCon Prague 2022)Do you know what your Drupal is doing Observe it! (DrupalCon Prague 2022)
Do you know what your Drupal is doing Observe it! (DrupalCon Prague 2022)sparkfabrik
 
Do you know what your Drupal is doing_ Observe it!
Do you know what your Drupal is doing_ Observe it!Do you know what your Drupal is doing_ Observe it!
Do you know what your Drupal is doing_ Observe it!sparkfabrik
 
Progettare e sviluppare soluzioni serverless con AWS
Progettare e sviluppare soluzioni serverless con AWSProgettare e sviluppare soluzioni serverless con AWS
Progettare e sviluppare soluzioni serverless con AWSsparkfabrik
 
From React to React Native - Things I wish I knew when I started
From React to React Native - Things I wish I knew when I startedFrom React to React Native - Things I wish I knew when I started
From React to React Native - Things I wish I knew when I startedsparkfabrik
 
Headless Drupal: A modern approach to (micro)services and APIs
Headless Drupal: A modern approach to (micro)services and APIsHeadless Drupal: A modern approach to (micro)services and APIs
Headless Drupal: A modern approach to (micro)services and APIssparkfabrik
 
Cloud-Native Drupal: a survival guide
Cloud-Native Drupal: a survival guideCloud-Native Drupal: a survival guide
Cloud-Native Drupal: a survival guidesparkfabrik
 
Mobile Development: una introduzione per Web Developers
Mobile Development: una introduzione per Web DevelopersMobile Development: una introduzione per Web Developers
Mobile Development: una introduzione per Web Developerssparkfabrik
 

Mehr von sparkfabrik (20)

KCD Italy 2023 - Secure Software Supply chain for OCI Artifact on Kubernetes
KCD Italy 2023 - Secure Software Supply chain for OCI Artifact on KubernetesKCD Italy 2023 - Secure Software Supply chain for OCI Artifact on Kubernetes
KCD Italy 2023 - Secure Software Supply chain for OCI Artifact on Kubernetes
 
20231129 - Platform @ localhost 2023 - Application-driven infrastructure with...
20231129 - Platform @ localhost 2023 - Application-driven infrastructure with...20231129 - Platform @ localhost 2023 - Application-driven infrastructure with...
20231129 - Platform @ localhost 2023 - Application-driven infrastructure with...
 
IAD 2023 - 22 Years of Agile and all I got is this lousy t-shirt
IAD 2023 - 22 Years of Agile and all I got is this lousy t-shirtIAD 2023 - 22 Years of Agile and all I got is this lousy t-shirt
IAD 2023 - 22 Years of Agile and all I got is this lousy t-shirt
 
2023 - Drupalcon - How Drupal builds your pages
2023 - Drupalcon - How Drupal builds your pages2023 - Drupalcon - How Drupal builds your pages
2023 - Drupalcon - How Drupal builds your pages
 
2023 - TAC23 - Agile HR - Racconti dal fronte
2023 - TAC23 - Agile HR - Racconti dal fronte2023 - TAC23 - Agile HR - Racconti dal fronte
2023 - TAC23 - Agile HR - Racconti dal fronte
 
CodeMotion 2023 - Deep dive nella supply chain della nostra infrastruttura cl...
CodeMotion 2023 - Deep dive nella supply chain della nostra infrastruttura cl...CodeMotion 2023 - Deep dive nella supply chain della nostra infrastruttura cl...
CodeMotion 2023 - Deep dive nella supply chain della nostra infrastruttura cl...
 
What is the Secure Supply Chain and the Current State of the PHP Ecosystem
What is the Secure Supply Chain and the Current State of the PHP EcosystemWhat is the Secure Supply Chain and the Current State of the PHP Ecosystem
What is the Secure Supply Chain and the Current State of the PHP Ecosystem
 
UX e Web sostenibile (UXday 2023).pdf
UX e Web sostenibile (UXday 2023).pdfUX e Web sostenibile (UXday 2023).pdf
UX e Web sostenibile (UXday 2023).pdf
 
Drupal Dev Days Vienna 2023 - What is the secure software supply chain and th...
Drupal Dev Days Vienna 2023 - What is the secure software supply chain and th...Drupal Dev Days Vienna 2023 - What is the secure software supply chain and th...
Drupal Dev Days Vienna 2023 - What is the secure software supply chain and th...
 
Deep dive nella supply chain della nostra infrastruttura cloud
Deep dive nella supply chain della nostra infrastruttura cloudDeep dive nella supply chain della nostra infrastruttura cloud
Deep dive nella supply chain della nostra infrastruttura cloud
 
KCD Italy 2022 - Application driven infrastructure with Crossplane
KCD Italy 2022 - Application driven infrastructure with CrossplaneKCD Italy 2022 - Application driven infrastructure with Crossplane
KCD Italy 2022 - Application driven infrastructure with Crossplane
 
Come Drupal costruisce le tue pagine
Come Drupal costruisce le tue pagineCome Drupal costruisce le tue pagine
Come Drupal costruisce le tue pagine
 
Drupal 10: un framework PHP di sviluppo Cloud Native moderno
Drupal 10: un framework PHP di sviluppo Cloud Native modernoDrupal 10: un framework PHP di sviluppo Cloud Native moderno
Drupal 10: un framework PHP di sviluppo Cloud Native moderno
 
Do you know what your Drupal is doing Observe it! (DrupalCon Prague 2022)
Do you know what your Drupal is doing Observe it! (DrupalCon Prague 2022)Do you know what your Drupal is doing Observe it! (DrupalCon Prague 2022)
Do you know what your Drupal is doing Observe it! (DrupalCon Prague 2022)
 
Do you know what your Drupal is doing_ Observe it!
Do you know what your Drupal is doing_ Observe it!Do you know what your Drupal is doing_ Observe it!
Do you know what your Drupal is doing_ Observe it!
 
Progettare e sviluppare soluzioni serverless con AWS
Progettare e sviluppare soluzioni serverless con AWSProgettare e sviluppare soluzioni serverless con AWS
Progettare e sviluppare soluzioni serverless con AWS
 
From React to React Native - Things I wish I knew when I started
From React to React Native - Things I wish I knew when I startedFrom React to React Native - Things I wish I knew when I started
From React to React Native - Things I wish I knew when I started
 
Headless Drupal: A modern approach to (micro)services and APIs
Headless Drupal: A modern approach to (micro)services and APIsHeadless Drupal: A modern approach to (micro)services and APIs
Headless Drupal: A modern approach to (micro)services and APIs
 
Cloud-Native Drupal: a survival guide
Cloud-Native Drupal: a survival guideCloud-Native Drupal: a survival guide
Cloud-Native Drupal: a survival guide
 
Mobile Development: una introduzione per Web Developers
Mobile Development: una introduzione per Web DevelopersMobile Development: una introduzione per Web Developers
Mobile Development: una introduzione per Web Developers
 

Kürzlich hochgeladen

CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂️CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️anilsa9823
 
Unlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language ModelsUnlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language Modelsaagamshah0812
 
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsAlberto González Trastoy
 
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerHow To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerThousandEyes
 
How To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.jsHow To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.jsAndolasoft Inc
 
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...harshavardhanraghave
 
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...kellynguyen01
 
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...ICS
 
Hand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxHand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxbodapatigopi8531
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️Delhi Call girls
 
5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdfWave PLM
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providermohitmore19
 
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...OnePlan Solutions
 
A Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxA Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxComplianceQuest1
 
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...MyIntelliSource, Inc.
 
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...MyIntelliSource, Inc.
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVshikhaohhpro
 

Kürzlich hochgeladen (20)

CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂️CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️
 
Unlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language ModelsUnlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language Models
 
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
 
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerHow To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
 
Microsoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdfMicrosoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdf
 
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICECHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
 
How To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.jsHow To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.js
 
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
 
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
 
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
 
Hand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxHand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptx
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
 
5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service provider
 
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
 
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS LiveVip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
 
A Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxA Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docx
 
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
 
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTV
 

Drupal 8 - Corso frontend development

  • 1.
  • 4. Andrea Panisson… Who? I work in as frontend developer. I care UI, IA, Drupal Theming and I care about clients.
  • 5. What’s new in Drupal 8 for themers D7  PHPTemplate  Theme functions + template files  Structured markup in core and ‘hardcoded’ classes  HTML D8  Twig  Template files  Minimal markup and classes in core  HTML5 in core
  • 6. Twig? Twig is a modern PHP-based compiled templating language.
  • 7. What's new in Drupal 8 for themers & the Twig template engine.
  • 8.  PHPtemplate  theme functions  markup in core Farewell to
  • 9. Welcome to  No more markup in core  All through template files  HTML5  Twig
  • 11. Twig: what & why What?  A template engine for PHP Why?  Twig was created by people behind Synfony2  Synfony2 was integrated in Drupal 8 core
  • 12. Twig was chosen because it was the best choice after comparing various templating languages. "… We don't have Twig because we have Symfony. It's more that, we have Twig because it's AWESOME" - Scott Reeves, @Cottser “Twig…because it's AWESOME”
  • 13. But why abandoning PHPtemplate? 1. Syntax 2. Inconsistency 3. Complexity 4. Redundancy 5. Security
  • 15. #1. D8 syntax: TWIG All variables are printed the same way
  • 16. #2. Inconsistency D7different ways to do the same thing:  Template files or Theme functions.  Theme functions or render arrays D8  Only template files  Only render arrays
  • 18. #3. D8: less complexity D8 is boring!
  • 19. #4. D7: redundancy There's a lot of duplicated code in themes, we often have multiple files with the same lines of code.
  • 20. #4. D8: less redundancy No need to repeat code between templates, we can extend templates with Twig.
  • 21. #5. Security D7 In a PHPTemplate file you can print all sort of unsanitized data, even delete a table from your DB. D8 In Twig this is not possible, Twig's autoescape feature is enabled by default.
  • 22. TWIG: no more conflict backend - frontend They are now separated!
  • 23. TWIG: easy to learn!
  • 25. Twig: no more var drilling Drupal 7 and PHPtemplate Drupal 8 and Twig
  • 34. Twig: includes Template files are reusable, thanks to Twig includes http://twig.sensiolabs.org/doc/tags/include.html {% include “footer.html.twig" %} Or using namespaces: {% include “@my_theme/partials/footer.html.twig" %}
  • 35. Twig coding standard (T.c.s.)  Generic Twig coding standards: http://twig.sensiolabs.org/doc/coding_standards.html  Twig in Drupal coding standards: http://drupal.org/node/1823416
  • 36. T.c.s. - HTML attributes In Drupal core, we will print only the class attribute specially, all the others will be printed as part of {{ attributes }}. The reason for this is that it needs to be very easy for front end developers to be able to add a class, anywhere
  • 38. T.c.s. - Comments  Singleline:  Multiline
  • 40. And so, Twig advantages:  a clear separation between the logic and the view  no more PHP code inside your template files  it's not only used in Drupal core, so it's not a Drupaly-thing
  • 42. YAML Yet Another Markup Language* * YAML Ain't Markup Language "YAML is a human friendly data serialization standard for all programming languages." -yaml.org Pronounced “yamel” (rhymes with camel).
  • 44. Why YAML?  YAML is both human editable and machine readable.  .yml files are not Drupal specific like .info files. And why not XML?  XML would require a Drupal specific schema. Or JSON?  JSON doesn't allow comments.  Non-ASCII characters require escaping in JSON.
  • 45. Theme folder structure The directory structure of Drupal 8 has changed! https://www.drupal.org/node/2349803
  • 47. /themes For themes that should be available to all sites. /sites/{site}/themes For themes that should be available on a specific site (on a multisite installation). Location of themes
  • 49. Most common theme files *.info.yml *.libraries.yml *.breakpoints.yml *.theme Theme folder structure: https://www.drupal.org/node/2349803
  • 50. *.info.yml (ex *.info)  A theme must contain an .info.yml file to define the theme.  Among other things the .info.yml files defines meta data, style sheets, and block regions.  This is the only required file in the theme.
  • 51. *.libraries.yml  The .libraries.yml file is used to define JavaScript and CSS libraries that can be loaded by the theme.  A library as a collection of CSS and JS.
  • 52. *.libraries.yml Libraries are called in the info file: and defined in the *.libraries.yml file:
  • 53. *.breakpoints.yml  Breakpoints define where a responsive design needs to change in order to respond to different devices.  Breakpoints are defined in a .breakpoints.yml file
  • 54. *.theme (ex template.php)  The .theme file is a PHP file that contains all the conditional logic and data (pre)processing of the output.
  • 56. The new theme layer
  • 57. Bye bye theming functions! ALL GONE: All of the theme() functions have been converted to Twig templates.
  • 58. New theme hooks  Theme suggestions hook_theme_suggestions() hook_theme_suggestions_HOOK()  Theme suggestions alter: hook_theme_suggestions_alter(), hook_theme_suggestions_HOOK_alter()  Theme preprocess: THEME_preprocess(&$variables, $hook), THEME_preprocess_HOOK(&$variables) https://api.drupal.org/api/drupal/core!lib!Drupal!Core!Render!theme.api.php/group/themeable/8
  • 59. Removed process hooks  The process layer (hook_process and hook_process_HOOK) is gone!
  • 60. The preprocess layer  The preprocess layer still exists, but it's used for a different purpose.  In Drupal 8, the preprocess layer should not be used to add css classes.  This should be done in the template files. https://www.drupal.org/node/2325067
  • 61. Drupal 8 core themes
  • 62. Drupal 8 core themes  bartik  seven  stark  classy  stable Backwards compatibility throughout the Drupal 8 cycle Default admin theme Default theme Drupal core markup test theme
  • 63. Drupal 8 core themes: bartik A flexible, recolorable theme with many regions and a responsive, mobile-first layout. The default theme in Drupal 8.
  • 64. Drupal 8 core themes: seven The default administration theme for Drupal 8. Now fully responsive.
  • 65. Drupal 8 core themes: stark An intentionally plain theme with almost no styling to demonstrate default Drupal’s HTML and CSS. Stark only outputs html and css from modules.  Add no CSS  Add no templates
  • 66. Drupal 8 core themes: stable The Stable theme will function as a backwards compatibility layer for Drupal 8's core markup, CSS and JS. A theme will always use Stable as the base theme unless you set in your theme .info.yml file.
  • 67. Drupal 8 core themes: classy The classes from core have been moved into the classy base theme. Now all template files in core are “classless”. Is the base theme that Seven and Bartik will extend from.
  • 69. Drupal 8 core templates core/modules/system/templates
  • 70. New CSS architecture SMACSS Scalable and Modular Architecture for CSS • Base • Layout • Component • State • Theme BEM Block Element Modifier naming convention .block__element--modifier
  • 72. Development tools Before start with theme development (Drupal development) let’s get some tools: Drush: http://www.drush.org Drupal Console: http://drupalconsole.com Devel module (& Kint): http://drupal.org/project/devel
  • 73. Installing composer… curl -sS https://getcomposer.org/installer | php mv composer.phar /usr/local/bin/composer https://getcomposer.org/doc/00-intro.md#globally
  • 74. Install Drupal console / drush Edit (global) composer.json and then run composer update
  • 75. Install Drupal console / drush composer global require drush/drush:dev-master composer global require drupal/console:@stable Remember to add the binaries composer directory to your path, i.e. $ echo "PATH=$PATH:~/.composer/vendor/bin" >> ~/.bash_profile
  • 76. Most useful drush commands:  Clear cache drush cr  Download / enable a module drush en module_name  HELP ME! drush help
  • 77. Most useful console commands:  Generate a theme: console generate:theme  More to come... * * Please, RTFM!
  • 78. Enable debugging: the manual way  Locate services.yml file (sites/default/services.yml)  If services.yml does not yet exist copy default.services.yml and rename it to services.yml  Edit the services.yml file and enable one or more of the debugging options  Rebuild cache
  • 79. Enable debugging: the manual way (continue) parameters: twig.config: # Twig debugging: debug: true # Twig auto-reload: auto_reload: true # Twig cache: cache: true
  • 81. Disable render cache Drupal caches any rendering it performs for blocks and entities, to speed up subsequent page loads. This means that changes to Twig templates for these will not take effect immediately.
  • 82. Disable render cache  add the following lines at the bottom of settings.php if (file_exists(__DIR__ . '/settings.local.php')) { include __DIR__ . '/settings.local.php'; }  copy sites/example.settings.local.php to sites/default/settings.local.php  clear the Drupal caches.
  • 83. Disable render cache In settings.local.php:  disable the render cache (this includes the page cache). $settings['cache']['bins']['render'] = 'cache.backend.null';  disable Dynamic Page Cache. $settings['cache']['bins']['dynamic_page_cache'] = 'cache.backend.null';
  • 84. Devel and Kint drush dl devel Kint, the new Krumo http://raveren.github.io/kint/
  • 85. Twig: compiled in PHP template Twig template engine takes the template file and converts it into a 'compiled' PHP template in sites/default/files/php/twig/* (drush cr clean this folder too)
  • 86. Resources  Twig official: http://twig.sensiolabs.org/  Theming Drupal 8: https://drupal.org/theme-guide/8  The Drupal 8 Theming guide: http://d8.sqndr.com/ More articles  Drupal 8 Theming Fundamentals, Part 1  Drupal 8 Theming Fundamentals, Part 2  A Tale of Two Base Themes in Drupal 8 core