SlideShare a Scribd company logo
1 of 48
Formerly known as Bysted, Propeople, Blink Reaction, Chainbizz and Geekpolis
Drupal 8 front-end point of view
Formerly known as Bysted, Propeople, Blink Reaction, Chainbizz and Geekpolis
About me
Hristina Hristova-Bozadzhieva
Front-end developer at FFW
E-mail: hristina.hristova@ffwagency.com
SlideShare: drupal8-theming
Formerly known as Bysted, Propeople, Blink Reaction, Chainbizz and Geekpolis
Agenda
1. Drupal 8 the new things
2. Custom theme structure
3. Classy – new base theme
4. Twig. What is Twig?
5. How to debbug and some examples in Drupal 8
6. Resources
Formerly known as Bysted, Propeople, Blink Reaction, Chainbizz and Geekpolis
What’s new in Drupal 8
27 Questions (and Answers) from My First Drupal 8 Site Build
Formerly known as Bysted, Propeople, Blink Reaction, Chainbizz and Geekpolis
A new template engine
Drupal 7 = PHP Template Drupal 8 = TWIG Template
 Conflict between Back-end & Front-end
 Potential Security Issues
 55 templates
154 functions
 Keeps Back-end & Frontend Separated
 More Secure – Autoescaping
 149 templates
21 functions
Formerly known as Bysted, Propeople, Blink Reaction, Chainbizz and Geekpolis
Responsive Theming
Drupal 8
Not just mobile friendly,
But mobile - first
Formerly known as Bysted, Propeople, Blink Reaction, Chainbizz and Geekpolis
Stop Divs It!!! – How it’s look drupal 7
Formerly known as Bysted, Propeople, Blink Reaction, Chainbizz and Geekpolis
HTML 5 out of the box
Formerly known as Bysted, Propeople, Blink Reaction, Chainbizz and Geekpolis
Drupal 8 WON’T support
 Internet Explorer 6
 Internet Explorer 7
 Internet Explorer 8
Formerly known as Bysted, Propeople, Blink Reaction, Chainbizz and Geekpolis
CSS build on SMACSS and BEM
https://smacss.com/
Bem
 base
 layout
 component
 state
 theme
https://www.drupal.org/node/1887918
Formerly known as Bysted, Propeople, Blink Reaction, Chainbizz and Geekpolis
Views in Core
Formerly known as Bysted, Propeople, Blink Reaction, Chainbizz and Geekpolis
Views = fully customizable…
With the Drupal 8 views, you can customize:
 Admin listings
 Sidebar content
 Image galleries
 Slideshows
 REST output
Formerly known as Bysted, Propeople, Blink Reaction, Chainbizz and Geekpolis
New field types
• E-mail
• Link/URL
• Phone number
• Data/Time
• Entity Reference
Formerly known as Bysted, Propeople, Blink Reaction, Chainbizz and Geekpolis
New Front-end libraries
Formerly known as Bysted, Propeople, Blink Reaction, Chainbizz and Geekpolis
Create custom theme
Formerly known as Bysted, Propeople, Blink Reaction, Chainbizz and Geekpolis
CLASSY – a new base theme
 Core/themes/classy
 In D8, default classes are stripped from Drupal core and
moved into the base theme Classy.
 The role of the Classy theme is to provide default markup and CSS
for Drupal.
Formerly known as Bysted, Propeople, Blink Reaction, Chainbizz and Geekpolis
No more - Sites/all/where/the/f*ck/is/my/themes
[root]/themes/my_theme
How to create theme: great article
by Matt Korostoff
Formerly known as Bysted, Propeople, Blink Reaction, Chainbizz and Geekpolis
Drupal 8 theme structure
• my_theme.info.yml
• my_theme.libraries.yml
• my_theme.breakpoints.yml
• my_theme.theme
• Css folder
• Templates folder
• Sass folder
• Img folder
• Js folder
Formerly known as Bysted, Propeople, Blink Reaction, Chainbizz and Geekpolis
theme.info.yml
name: [themename]
type: theme
description: This is my custom Drupal 8 Theme
base theme: classy
core: 8.x
engine: twig
screenshot: screenshot.png
# --- CSS ------------------------------------------
stylesheets:
all:
- css/styles.css
stylesheets-remove:
- normalize.css
# --- REGIONS --------------------------------------
regions:
header: ‘Header’...
# --- LIBRARIES --------------------------------------
libraries:
- [themename]/[namespace]
Formerly known as Bysted, Propeople, Blink Reaction, Chainbizz and Geekpolis
theme.libraries.yml
# Global for all pages
global:
version: 1.x
css:
css/slider.css: {}
js:
js/slider.js: {}
dependencies:
- core/jquery
Formerly known as Bysted, Propeople, Blink Reaction, Chainbizz and Geekpolis
theme.breakpoints.yml
my_theme.mobile:
label: mobile
mediaQuery: ''
weight: 0
multipliers: - 1x
my_theme.narrow:
label: narrow
mediaQuery: 'all and (min-width: 560px) and (max-width: 850px)'
weight: 1
multipliers: - 1.5x // supports Android
-2x // supports Mac retina display
my_theme.wide:
label: wide
mediaQuery: 'all and (min-width: 851px)'
weight: 2
multipliers: - 1x
Formerly known as Bysted, Propeople, Blink Reaction, Chainbizz and Geekpolis
theme.theme
• THEME.theme replace template.php
• Theme functions go here.
Formerly known as Bysted, Propeople, Blink Reaction, Chainbizz and Geekpolis
Formerly known as Bysted, Propeople, Blink Reaction, Chainbizz and Geekpolis
What is TWIG?
 Twig is a “modern” template language ->
symphony, used by other systems
+ It’s easy to learn 
 Twig is a template framework that has replaced
PHP Template in Drupal 8.
 fast, secure and flexible.
http://twig.sensiolabs.org/documentation
http://twig.sensiolabs.org/pdf/Twig.pdf
Formerly known as Bysted, Propeople, Blink Reaction, Chainbizz and Geekpolis
Intro to Twig
There are three delimiters you need to knows
• Print variables: {{ … }}
• Comments: {# … #}
• Execute statements: {% … %}
Formerly known as Bysted, Propeople, Blink Reaction, Chainbizz and Geekpolis
TWIG
 Variables can be accessed directly
in Twig.
 Classes can be drilled into to show
attributes:
<div {{ attributes }}>
{{ content }}
</div>
• Conditional statements:
{% if … %}{% endif %}
• Loops:
{% for … %}{% endfor %}
• Blocks:
{% block blockname %}...{% endblock
%}
• Extends:
{% extends ‘.....’ %}
Formerly known as Bysted, Propeople, Blink Reaction, Chainbizz and Geekpolis
Arrays
1. PHP
<?php
print $foo[‘bar’][‘und']->content['baz']['foo']['bar'];
?>
2. TWIG
{{ foo.bar.content.baz.foo.bar }}
Formerly known as Bysted, Propeople, Blink Reaction, Chainbizz and Geekpolis
Finding Stuff in Twig
1. Print all available variables
{{ dump() }}
2. Print content of specific variable
{{ dump(foo) }}
Formerly known as Bysted, Propeople, Blink Reaction, Chainbizz and Geekpolis
Loops
Twig template:
<h2>Organizers</h2>
<ul>
{% for user in users %}
<li>{{user.username}}</li>
{% endfor %}
</ul>
Output:
<h2>Organizers</h2>
<ul>
<li>Hrisi</li>
<li>John</li>
<li>Sean</li>
</ul>
Formerly known as Bysted, Propeople, Blink Reaction, Chainbizz and Geekpolis
Loops
{{ loop.length }}
{{ loop.first }}
{{ loop.last }}
{{ loop.index}}
{{% if loop.first %}}
…
{% elseif loop.index == 2 %}
…
{{% elseif loop.last %}}
…
{{% endif %}}
Formerly known as Bysted, Propeople, Blink Reaction, Chainbizz and Geekpolis
|FILTER
Twig template
{% set name = ‘Hrisi’ %}
<span>
{{ name|length}}
</span>
Output:
<span>5</span>
More info: http://twig.sensiolabs.org/doc/filters/index.html
Formerly known as Bysted, Propeople, Blink Reaction, Chainbizz and Geekpolis
Filters Reference
 abs
 batch
 capitalize
 convert_encoding
 date
 date_modify
 default
 escape
 first
 format
 join
 json_encode
 keys
 last
 length
 lower
 merge
 number_format
 raw
 replace
 reverse
 round
 slice
 sort
 split
 striptags
 title
 trim
 upper
 url_encode
Formerly known as Bysted, Propeople, Blink Reaction, Chainbizz and Geekpolis
First template {# base.twig #}
{% for post in posts %}
{% block post %}
<h1>{{ post.title }}</h1>
<p>{{ post.body }}</p>
{% endblock %}
{% endfor %}
Second template {# child.twig #}
{% extends "base.twig" %}
{% block post %}
<article>
<header>{{ post.title }}</header>
<section>{{ post.text }}</section>
</article>
{% endblock %}
TWIG Basics inheritance
Formerly known as Bysted, Propeople, Blink Reaction, Chainbizz and Geekpolis
TWIG inheritance result
{# child.twig #}
{% extends "base.twig" %}
{% block post %}
<article>
<header>{{ post.title }}</header>
<section>{{ post.text }}</section>
</article>
{% endblock %}
Now, when rendering
the child template
Formerly known as Bysted, Propeople, Blink Reaction, Chainbizz and Geekpolis
Formerly known as Bysted, Propeople, Blink Reaction, Chainbizz and Geekpolis
TOOLS
How to find stuff and debug
Formerly known as Bysted, Propeople, Blink Reaction, Chainbizz and Geekpolis
Where are the twig files?
 In the system templates folder
(/core/modules/system/templates)
you’ll find more than 40 templates
things like fields, nodes, pages, links.
 All templates for the theme:
[root]corethemesclassytemplates
 They are separated in groups
- layout
- block
- views
- content
- content-edit
- field
- navigation
- dataset
- forum
- user
- misc
Formerly known as Bysted, Propeople, Blink Reaction, Chainbizz and Geekpolis
Services.yml
 If services.yml does not yet exist; copy default.services.yml and rename it to services.yml.
 Locate the twig.config parameters in your services.yml and make changes there.
twig.config:
debug: true
 Twig auto-reload
auto_reload: true - Not recommended in production environments (Default: null).
 Twig cache
cache: false
Formerly known as Bysted, Propeople, Blink Reaction, Chainbizz and Geekpolis
SETTINGS.PHP
 Copy: sites/settings.local.php
 To: sites/default/settings.php
 In Settings.php uncomment:
if (file_exists(__DIR__ . '/settings.local.php')) {
include __DIR__ . '/settings.local.php';
}
Formerly known as Bysted, Propeople, Blink Reaction, Chainbizz and Geekpolis
Firebug
In firebug make sure that "Show Comments" is enabled:
Formerly known as Bysted, Propeople, Blink Reaction, Chainbizz and Geekpolis
Disable CSS cache and clear the
cache!!!
Formerly known as Bysted, Propeople, Blink Reaction, Chainbizz and Geekpolis
After refresh the page
Formerly known as Bysted, Propeople, Blink Reaction, Chainbizz and Geekpolis
Another Way
Devel module
• Download Devel module
• Install Devel + Kint
• Enable Devel and Kint
Formerly known as Bysted, Propeople, Blink Reaction, Chainbizz and Geekpolis
Kint == Krumo for Drupal8
{{ kint(page) }}
Formerly known as Bysted, Propeople, Blink Reaction, Chainbizz and Geekpolis
Formerly known as Bysted, Propeople, Blink Reaction, Chainbizz and Geekpolis
Resources and further reading
• A brilliant blog post about D8 theming (Savas)
• D8 theming guide (Sander)
• YAML formatting (Symfony)
• Intro to BEM (CSS Wizardry)
• Adding assets to pages (drupal.org)
• Twig documentation (Sensiolabs)
• Drupal-specific Twig filters (drupal.org)
• Twig coding standards (drupal.org)
• Twig debugging and devel (drupalize.me)
Formerly known as Bysted, Propeople, Blink Reaction, Chainbizz and Geekpolis
Questions
&
Answers
Thank you!

More Related Content

Viewers also liked

Drupal 8 introduction to theming
Drupal 8  introduction to themingDrupal 8  introduction to theming
Drupal 8 introduction to themingBrahampal Singh
 
Drupal 8: Theming. Lviv Drupal Cafe #4
Drupal 8: Theming. Lviv Drupal Cafe #4Drupal 8: Theming. Lviv Drupal Cafe #4
Drupal 8: Theming. Lviv Drupal Cafe #4Pavel Shevchuk
 
Drupal8 themingdeepdive drupaldevdays-montpellier17042015
Drupal8 themingdeepdive drupaldevdays-montpellier17042015Drupal8 themingdeepdive drupaldevdays-montpellier17042015
Drupal8 themingdeepdive drupaldevdays-montpellier17042015Romain Jarraud
 
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
 
[Srijan Wednesday Webinars] Drupal 8: Goodbye to 10 Years of Theming Headaches
[Srijan Wednesday Webinars] Drupal 8: Goodbye to 10 Years of Theming Headaches[Srijan Wednesday Webinars] Drupal 8: Goodbye to 10 Years of Theming Headaches
[Srijan Wednesday Webinars] Drupal 8: Goodbye to 10 Years of Theming HeadachesSrijan Technologies
 

Viewers also liked (7)

Twig
TwigTwig
Twig
 
Drupal 8 introduction to theming
Drupal 8  introduction to themingDrupal 8  introduction to theming
Drupal 8 introduction to theming
 
Drupal 8 theming
Drupal 8 themingDrupal 8 theming
Drupal 8 theming
 
Drupal 8: Theming. Lviv Drupal Cafe #4
Drupal 8: Theming. Lviv Drupal Cafe #4Drupal 8: Theming. Lviv Drupal Cafe #4
Drupal 8: Theming. Lviv Drupal Cafe #4
 
Drupal8 themingdeepdive drupaldevdays-montpellier17042015
Drupal8 themingdeepdive drupaldevdays-montpellier17042015Drupal8 themingdeepdive drupaldevdays-montpellier17042015
Drupal8 themingdeepdive drupaldevdays-montpellier17042015
 
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
 
[Srijan Wednesday Webinars] Drupal 8: Goodbye to 10 Years of Theming Headaches
[Srijan Wednesday Webinars] Drupal 8: Goodbye to 10 Years of Theming Headaches[Srijan Wednesday Webinars] Drupal 8: Goodbye to 10 Years of Theming Headaches
[Srijan Wednesday Webinars] Drupal 8: Goodbye to 10 Years of Theming Headaches
 

Similar to Drupal8 theming

Drupal 8: frontend development
Drupal 8: frontend developmentDrupal 8: frontend development
Drupal 8: frontend developmentsparkfabrik
 
Top 8 Improvements in Drupal 8
Top 8 Improvements in Drupal 8Top 8 Improvements in Drupal 8
Top 8 Improvements in Drupal 8Angela Byron
 
Drupal theming - a practical approach (European Drupal Days 2015)
Drupal theming - a practical approach (European Drupal Days 2015)Drupal theming - a practical approach (European Drupal Days 2015)
Drupal theming - a practical approach (European Drupal Days 2015)Eugenio Minardi
 
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
 
Intro to Theming Drupal, FOSSLC Summer Camp 2010
Intro to Theming Drupal, FOSSLC Summer Camp 2010Intro to Theming Drupal, FOSSLC Summer Camp 2010
Intro to Theming Drupal, FOSSLC Summer Camp 2010Emma Jane Hogbin Westby
 
Crash Course in Theme Surgery
Crash Course in Theme SurgeryCrash Course in Theme Surgery
Crash Course in Theme SurgeryRational Frank
 
Fronteers - Drupal 7 ux
Fronteers   - Drupal 7 uxFronteers   - Drupal 7 ux
Fronteers - Drupal 7 uxBojhan
 
Drupalcon cph
Drupalcon cphDrupalcon cph
Drupalcon cphcyberswat
 
Building Websites of the Future With Drupal 7
Building Websites of the Future With Drupal 7Building Websites of the Future With Drupal 7
Building Websites of the Future With Drupal 7Jay Epstein
 
Building Websites of the Future With Drupal 7
Building Websites of the Future With Drupal 7Building Websites of the Future With Drupal 7
Building Websites of the Future With Drupal 7Jay Epstein
 
DrupalEasy: Intro to Theme Development
DrupalEasy: Intro to Theme DevelopmentDrupalEasy: Intro to Theme Development
DrupalEasy: Intro to Theme Developmentultimike
 
Introduction To Drupal
Introduction To DrupalIntroduction To Drupal
Introduction To DrupalLauren Roth
 
Drupal in 30 Minutes
Drupal in 30 MinutesDrupal in 30 Minutes
Drupal in 30 MinutesRobert Carr
 
Everything You Need to Know About the Top Changes in Drupal 8
Everything You Need to Know About the Top Changes in Drupal 8Everything You Need to Know About the Top Changes in Drupal 8
Everything You Need to Know About the Top Changes in Drupal 8Acquia
 
Drupal 8: A story of growing up and getting off the island
Drupal 8: A story of growing up and getting off the islandDrupal 8: A story of growing up and getting off the island
Drupal 8: A story of growing up and getting off the islandAngela Byron
 

Similar to Drupal8 theming (20)

Migrate in Drupal 8
Migrate in Drupal 8Migrate in Drupal 8
Migrate in Drupal 8
 
Static website generators
Static website generatorsStatic website generators
Static website generators
 
Drupal 8: frontend development
Drupal 8: frontend developmentDrupal 8: frontend development
Drupal 8: frontend development
 
Recipes for Drupal distributions
Recipes for Drupal distributionsRecipes for Drupal distributions
Recipes for Drupal distributions
 
Top 8 Improvements in Drupal 8
Top 8 Improvements in Drupal 8Top 8 Improvements in Drupal 8
Top 8 Improvements in Drupal 8
 
Drupal theming - a practical approach (European Drupal Days 2015)
Drupal theming - a practical approach (European Drupal Days 2015)Drupal theming - a practical approach (European Drupal Days 2015)
Drupal theming - a practical approach (European Drupal Days 2015)
 
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
 
Intro to Theming Drupal, FOSSLC Summer Camp 2010
Intro to Theming Drupal, FOSSLC Summer Camp 2010Intro to Theming Drupal, FOSSLC Summer Camp 2010
Intro to Theming Drupal, FOSSLC Summer Camp 2010
 
Django at Scale
Django at ScaleDjango at Scale
Django at Scale
 
Crash Course in Theme Surgery
Crash Course in Theme SurgeryCrash Course in Theme Surgery
Crash Course in Theme Surgery
 
Design to Theme @ CMSExpo
Design to Theme @ CMSExpoDesign to Theme @ CMSExpo
Design to Theme @ CMSExpo
 
Fronteers - Drupal 7 ux
Fronteers   - Drupal 7 uxFronteers   - Drupal 7 ux
Fronteers - Drupal 7 ux
 
Drupalcon cph
Drupalcon cphDrupalcon cph
Drupalcon cph
 
Building Websites of the Future With Drupal 7
Building Websites of the Future With Drupal 7Building Websites of the Future With Drupal 7
Building Websites of the Future With Drupal 7
 
Building Websites of the Future With Drupal 7
Building Websites of the Future With Drupal 7Building Websites of the Future With Drupal 7
Building Websites of the Future With Drupal 7
 
DrupalEasy: Intro to Theme Development
DrupalEasy: Intro to Theme DevelopmentDrupalEasy: Intro to Theme Development
DrupalEasy: Intro to Theme Development
 
Introduction To Drupal
Introduction To DrupalIntroduction To Drupal
Introduction To Drupal
 
Drupal in 30 Minutes
Drupal in 30 MinutesDrupal in 30 Minutes
Drupal in 30 Minutes
 
Everything You Need to Know About the Top Changes in Drupal 8
Everything You Need to Know About the Top Changes in Drupal 8Everything You Need to Know About the Top Changes in Drupal 8
Everything You Need to Know About the Top Changes in Drupal 8
 
Drupal 8: A story of growing up and getting off the island
Drupal 8: A story of growing up and getting off the islandDrupal 8: A story of growing up and getting off the island
Drupal 8: A story of growing up and getting off the island
 

Recently uploaded

Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...confluent
 
Keeping your build tool updated in a multi repository world
Keeping your build tool updated in a multi repository worldKeeping your build tool updated in a multi repository world
Keeping your build tool updated in a multi repository worldRoberto Pérez Alcolea
 
Large Language Models for Test Case Evolution and Repair
Large Language Models for Test Case Evolution and RepairLarge Language Models for Test Case Evolution and Repair
Large Language Models for Test Case Evolution and RepairLionel Briand
 
Effectively Troubleshoot 9 Types of OutOfMemoryError
Effectively Troubleshoot 9 Types of OutOfMemoryErrorEffectively Troubleshoot 9 Types of OutOfMemoryError
Effectively Troubleshoot 9 Types of OutOfMemoryErrorTier1 app
 
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...OnePlan Solutions
 
What’s New in VictoriaMetrics: Q1 2024 Updates
What’s New in VictoriaMetrics: Q1 2024 UpdatesWhat’s New in VictoriaMetrics: Q1 2024 Updates
What’s New in VictoriaMetrics: Q1 2024 UpdatesVictoriaMetrics
 
Ronisha Informatics Private Limited Catalogue
Ronisha Informatics Private Limited CatalogueRonisha Informatics Private Limited Catalogue
Ronisha Informatics Private Limited Catalogueitservices996
 
Understanding Flamingo - DeepMind's VLM Architecture
Understanding Flamingo - DeepMind's VLM ArchitectureUnderstanding Flamingo - DeepMind's VLM Architecture
Understanding Flamingo - DeepMind's VLM Architecturerahul_net
 
Simplifying Microservices & Apps - The art of effortless development - Meetup...
Simplifying Microservices & Apps - The art of effortless development - Meetup...Simplifying Microservices & Apps - The art of effortless development - Meetup...
Simplifying Microservices & Apps - The art of effortless development - Meetup...Rob Geurden
 
Amazon Bedrock in Action - presentation of the Bedrock's capabilities
Amazon Bedrock in Action - presentation of the Bedrock's capabilitiesAmazon Bedrock in Action - presentation of the Bedrock's capabilities
Amazon Bedrock in Action - presentation of the Bedrock's capabilitiesKrzysztofKkol1
 
Odoo 14 - eLearning Module In Odoo 14 Enterprise
Odoo 14 - eLearning Module In Odoo 14 EnterpriseOdoo 14 - eLearning Module In Odoo 14 Enterprise
Odoo 14 - eLearning Module In Odoo 14 Enterprisepreethippts
 
Precise and Complete Requirements? An Elusive Goal
Precise and Complete Requirements? An Elusive GoalPrecise and Complete Requirements? An Elusive Goal
Precise and Complete Requirements? An Elusive GoalLionel Briand
 
Machine Learning Software Engineering Patterns and Their Engineering
Machine Learning Software Engineering Patterns and Their EngineeringMachine Learning Software Engineering Patterns and Their Engineering
Machine Learning Software Engineering Patterns and Their EngineeringHironori Washizaki
 
SpotFlow: Tracking Method Calls and States at Runtime
SpotFlow: Tracking Method Calls and States at RuntimeSpotFlow: Tracking Method Calls and States at Runtime
SpotFlow: Tracking Method Calls and States at Runtimeandrehoraa
 
Exploring Selenium_Appium Frameworks for Seamless Integration with HeadSpin.pdf
Exploring Selenium_Appium Frameworks for Seamless Integration with HeadSpin.pdfExploring Selenium_Appium Frameworks for Seamless Integration with HeadSpin.pdf
Exploring Selenium_Appium Frameworks for Seamless Integration with HeadSpin.pdfkalichargn70th171
 
VictoriaMetrics Anomaly Detection Updates: Q1 2024
VictoriaMetrics Anomaly Detection Updates: Q1 2024VictoriaMetrics Anomaly Detection Updates: Q1 2024
VictoriaMetrics Anomaly Detection Updates: Q1 2024VictoriaMetrics
 
Post Quantum Cryptography – The Impact on Identity
Post Quantum Cryptography – The Impact on IdentityPost Quantum Cryptography – The Impact on Identity
Post Quantum Cryptography – The Impact on Identityteam-WIBU
 
Not a Kubernetes fan? The state of PaaS in 2024
Not a Kubernetes fan? The state of PaaS in 2024Not a Kubernetes fan? The state of PaaS in 2024
Not a Kubernetes fan? The state of PaaS in 2024Anthony Dahanne
 
Tech Tuesday Slides - Introduction to Project Management with OnePlan's Work ...
Tech Tuesday Slides - Introduction to Project Management with OnePlan's Work ...Tech Tuesday Slides - Introduction to Project Management with OnePlan's Work ...
Tech Tuesday Slides - Introduction to Project Management with OnePlan's Work ...OnePlan Solutions
 
2024 DevNexus Patterns for Resiliency: Shuffle shards
2024 DevNexus Patterns for Resiliency: Shuffle shards2024 DevNexus Patterns for Resiliency: Shuffle shards
2024 DevNexus Patterns for Resiliency: Shuffle shardsChristopher Curtin
 

Recently uploaded (20)

Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...
 
Keeping your build tool updated in a multi repository world
Keeping your build tool updated in a multi repository worldKeeping your build tool updated in a multi repository world
Keeping your build tool updated in a multi repository world
 
Large Language Models for Test Case Evolution and Repair
Large Language Models for Test Case Evolution and RepairLarge Language Models for Test Case Evolution and Repair
Large Language Models for Test Case Evolution and Repair
 
Effectively Troubleshoot 9 Types of OutOfMemoryError
Effectively Troubleshoot 9 Types of OutOfMemoryErrorEffectively Troubleshoot 9 Types of OutOfMemoryError
Effectively Troubleshoot 9 Types of OutOfMemoryError
 
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...
 
What’s New in VictoriaMetrics: Q1 2024 Updates
What’s New in VictoriaMetrics: Q1 2024 UpdatesWhat’s New in VictoriaMetrics: Q1 2024 Updates
What’s New in VictoriaMetrics: Q1 2024 Updates
 
Ronisha Informatics Private Limited Catalogue
Ronisha Informatics Private Limited CatalogueRonisha Informatics Private Limited Catalogue
Ronisha Informatics Private Limited Catalogue
 
Understanding Flamingo - DeepMind's VLM Architecture
Understanding Flamingo - DeepMind's VLM ArchitectureUnderstanding Flamingo - DeepMind's VLM Architecture
Understanding Flamingo - DeepMind's VLM Architecture
 
Simplifying Microservices & Apps - The art of effortless development - Meetup...
Simplifying Microservices & Apps - The art of effortless development - Meetup...Simplifying Microservices & Apps - The art of effortless development - Meetup...
Simplifying Microservices & Apps - The art of effortless development - Meetup...
 
Amazon Bedrock in Action - presentation of the Bedrock's capabilities
Amazon Bedrock in Action - presentation of the Bedrock's capabilitiesAmazon Bedrock in Action - presentation of the Bedrock's capabilities
Amazon Bedrock in Action - presentation of the Bedrock's capabilities
 
Odoo 14 - eLearning Module In Odoo 14 Enterprise
Odoo 14 - eLearning Module In Odoo 14 EnterpriseOdoo 14 - eLearning Module In Odoo 14 Enterprise
Odoo 14 - eLearning Module In Odoo 14 Enterprise
 
Precise and Complete Requirements? An Elusive Goal
Precise and Complete Requirements? An Elusive GoalPrecise and Complete Requirements? An Elusive Goal
Precise and Complete Requirements? An Elusive Goal
 
Machine Learning Software Engineering Patterns and Their Engineering
Machine Learning Software Engineering Patterns and Their EngineeringMachine Learning Software Engineering Patterns and Their Engineering
Machine Learning Software Engineering Patterns and Their Engineering
 
SpotFlow: Tracking Method Calls and States at Runtime
SpotFlow: Tracking Method Calls and States at RuntimeSpotFlow: Tracking Method Calls and States at Runtime
SpotFlow: Tracking Method Calls and States at Runtime
 
Exploring Selenium_Appium Frameworks for Seamless Integration with HeadSpin.pdf
Exploring Selenium_Appium Frameworks for Seamless Integration with HeadSpin.pdfExploring Selenium_Appium Frameworks for Seamless Integration with HeadSpin.pdf
Exploring Selenium_Appium Frameworks for Seamless Integration with HeadSpin.pdf
 
VictoriaMetrics Anomaly Detection Updates: Q1 2024
VictoriaMetrics Anomaly Detection Updates: Q1 2024VictoriaMetrics Anomaly Detection Updates: Q1 2024
VictoriaMetrics Anomaly Detection Updates: Q1 2024
 
Post Quantum Cryptography – The Impact on Identity
Post Quantum Cryptography – The Impact on IdentityPost Quantum Cryptography – The Impact on Identity
Post Quantum Cryptography – The Impact on Identity
 
Not a Kubernetes fan? The state of PaaS in 2024
Not a Kubernetes fan? The state of PaaS in 2024Not a Kubernetes fan? The state of PaaS in 2024
Not a Kubernetes fan? The state of PaaS in 2024
 
Tech Tuesday Slides - Introduction to Project Management with OnePlan's Work ...
Tech Tuesday Slides - Introduction to Project Management with OnePlan's Work ...Tech Tuesday Slides - Introduction to Project Management with OnePlan's Work ...
Tech Tuesday Slides - Introduction to Project Management with OnePlan's Work ...
 
2024 DevNexus Patterns for Resiliency: Shuffle shards
2024 DevNexus Patterns for Resiliency: Shuffle shards2024 DevNexus Patterns for Resiliency: Shuffle shards
2024 DevNexus Patterns for Resiliency: Shuffle shards
 

Drupal8 theming

  • 1. Formerly known as Bysted, Propeople, Blink Reaction, Chainbizz and Geekpolis Drupal 8 front-end point of view
  • 2. Formerly known as Bysted, Propeople, Blink Reaction, Chainbizz and Geekpolis About me Hristina Hristova-Bozadzhieva Front-end developer at FFW E-mail: hristina.hristova@ffwagency.com SlideShare: drupal8-theming
  • 3. Formerly known as Bysted, Propeople, Blink Reaction, Chainbizz and Geekpolis Agenda 1. Drupal 8 the new things 2. Custom theme structure 3. Classy – new base theme 4. Twig. What is Twig? 5. How to debbug and some examples in Drupal 8 6. Resources
  • 4. Formerly known as Bysted, Propeople, Blink Reaction, Chainbizz and Geekpolis What’s new in Drupal 8 27 Questions (and Answers) from My First Drupal 8 Site Build
  • 5. Formerly known as Bysted, Propeople, Blink Reaction, Chainbizz and Geekpolis A new template engine Drupal 7 = PHP Template Drupal 8 = TWIG Template  Conflict between Back-end & Front-end  Potential Security Issues  55 templates 154 functions  Keeps Back-end & Frontend Separated  More Secure – Autoescaping  149 templates 21 functions
  • 6. Formerly known as Bysted, Propeople, Blink Reaction, Chainbizz and Geekpolis Responsive Theming Drupal 8 Not just mobile friendly, But mobile - first
  • 7. Formerly known as Bysted, Propeople, Blink Reaction, Chainbizz and Geekpolis Stop Divs It!!! – How it’s look drupal 7
  • 8. Formerly known as Bysted, Propeople, Blink Reaction, Chainbizz and Geekpolis HTML 5 out of the box
  • 9. Formerly known as Bysted, Propeople, Blink Reaction, Chainbizz and Geekpolis Drupal 8 WON’T support  Internet Explorer 6  Internet Explorer 7  Internet Explorer 8
  • 10. Formerly known as Bysted, Propeople, Blink Reaction, Chainbizz and Geekpolis CSS build on SMACSS and BEM https://smacss.com/ Bem  base  layout  component  state  theme https://www.drupal.org/node/1887918
  • 11. Formerly known as Bysted, Propeople, Blink Reaction, Chainbizz and Geekpolis Views in Core
  • 12. Formerly known as Bysted, Propeople, Blink Reaction, Chainbizz and Geekpolis Views = fully customizable… With the Drupal 8 views, you can customize:  Admin listings  Sidebar content  Image galleries  Slideshows  REST output
  • 13. Formerly known as Bysted, Propeople, Blink Reaction, Chainbizz and Geekpolis New field types • E-mail • Link/URL • Phone number • Data/Time • Entity Reference
  • 14. Formerly known as Bysted, Propeople, Blink Reaction, Chainbizz and Geekpolis New Front-end libraries
  • 15. Formerly known as Bysted, Propeople, Blink Reaction, Chainbizz and Geekpolis Create custom theme
  • 16. Formerly known as Bysted, Propeople, Blink Reaction, Chainbizz and Geekpolis CLASSY – a new base theme  Core/themes/classy  In D8, default classes are stripped from Drupal core and moved into the base theme Classy.  The role of the Classy theme is to provide default markup and CSS for Drupal.
  • 17. Formerly known as Bysted, Propeople, Blink Reaction, Chainbizz and Geekpolis No more - Sites/all/where/the/f*ck/is/my/themes [root]/themes/my_theme How to create theme: great article by Matt Korostoff
  • 18. Formerly known as Bysted, Propeople, Blink Reaction, Chainbizz and Geekpolis Drupal 8 theme structure • my_theme.info.yml • my_theme.libraries.yml • my_theme.breakpoints.yml • my_theme.theme • Css folder • Templates folder • Sass folder • Img folder • Js folder
  • 19. Formerly known as Bysted, Propeople, Blink Reaction, Chainbizz and Geekpolis theme.info.yml name: [themename] type: theme description: This is my custom Drupal 8 Theme base theme: classy core: 8.x engine: twig screenshot: screenshot.png # --- CSS ------------------------------------------ stylesheets: all: - css/styles.css stylesheets-remove: - normalize.css # --- REGIONS -------------------------------------- regions: header: ‘Header’... # --- LIBRARIES -------------------------------------- libraries: - [themename]/[namespace]
  • 20. Formerly known as Bysted, Propeople, Blink Reaction, Chainbizz and Geekpolis theme.libraries.yml # Global for all pages global: version: 1.x css: css/slider.css: {} js: js/slider.js: {} dependencies: - core/jquery
  • 21. Formerly known as Bysted, Propeople, Blink Reaction, Chainbizz and Geekpolis theme.breakpoints.yml my_theme.mobile: label: mobile mediaQuery: '' weight: 0 multipliers: - 1x my_theme.narrow: label: narrow mediaQuery: 'all and (min-width: 560px) and (max-width: 850px)' weight: 1 multipliers: - 1.5x // supports Android -2x // supports Mac retina display my_theme.wide: label: wide mediaQuery: 'all and (min-width: 851px)' weight: 2 multipliers: - 1x
  • 22. Formerly known as Bysted, Propeople, Blink Reaction, Chainbizz and Geekpolis theme.theme • THEME.theme replace template.php • Theme functions go here.
  • 23. Formerly known as Bysted, Propeople, Blink Reaction, Chainbizz and Geekpolis
  • 24. Formerly known as Bysted, Propeople, Blink Reaction, Chainbizz and Geekpolis What is TWIG?  Twig is a “modern” template language -> symphony, used by other systems + It’s easy to learn   Twig is a template framework that has replaced PHP Template in Drupal 8.  fast, secure and flexible. http://twig.sensiolabs.org/documentation http://twig.sensiolabs.org/pdf/Twig.pdf
  • 25. Formerly known as Bysted, Propeople, Blink Reaction, Chainbizz and Geekpolis Intro to Twig There are three delimiters you need to knows • Print variables: {{ … }} • Comments: {# … #} • Execute statements: {% … %}
  • 26. Formerly known as Bysted, Propeople, Blink Reaction, Chainbizz and Geekpolis TWIG  Variables can be accessed directly in Twig.  Classes can be drilled into to show attributes: <div {{ attributes }}> {{ content }} </div> • Conditional statements: {% if … %}{% endif %} • Loops: {% for … %}{% endfor %} • Blocks: {% block blockname %}...{% endblock %} • Extends: {% extends ‘.....’ %}
  • 27. Formerly known as Bysted, Propeople, Blink Reaction, Chainbizz and Geekpolis Arrays 1. PHP <?php print $foo[‘bar’][‘und']->content['baz']['foo']['bar']; ?> 2. TWIG {{ foo.bar.content.baz.foo.bar }}
  • 28. Formerly known as Bysted, Propeople, Blink Reaction, Chainbizz and Geekpolis Finding Stuff in Twig 1. Print all available variables {{ dump() }} 2. Print content of specific variable {{ dump(foo) }}
  • 29. Formerly known as Bysted, Propeople, Blink Reaction, Chainbizz and Geekpolis Loops Twig template: <h2>Organizers</h2> <ul> {% for user in users %} <li>{{user.username}}</li> {% endfor %} </ul> Output: <h2>Organizers</h2> <ul> <li>Hrisi</li> <li>John</li> <li>Sean</li> </ul>
  • 30. Formerly known as Bysted, Propeople, Blink Reaction, Chainbizz and Geekpolis Loops {{ loop.length }} {{ loop.first }} {{ loop.last }} {{ loop.index}} {{% if loop.first %}} … {% elseif loop.index == 2 %} … {{% elseif loop.last %}} … {{% endif %}}
  • 31. Formerly known as Bysted, Propeople, Blink Reaction, Chainbizz and Geekpolis |FILTER Twig template {% set name = ‘Hrisi’ %} <span> {{ name|length}} </span> Output: <span>5</span> More info: http://twig.sensiolabs.org/doc/filters/index.html
  • 32. Formerly known as Bysted, Propeople, Blink Reaction, Chainbizz and Geekpolis Filters Reference  abs  batch  capitalize  convert_encoding  date  date_modify  default  escape  first  format  join  json_encode  keys  last  length  lower  merge  number_format  raw  replace  reverse  round  slice  sort  split  striptags  title  trim  upper  url_encode
  • 33. Formerly known as Bysted, Propeople, Blink Reaction, Chainbizz and Geekpolis First template {# base.twig #} {% for post in posts %} {% block post %} <h1>{{ post.title }}</h1> <p>{{ post.body }}</p> {% endblock %} {% endfor %} Second template {# child.twig #} {% extends "base.twig" %} {% block post %} <article> <header>{{ post.title }}</header> <section>{{ post.text }}</section> </article> {% endblock %} TWIG Basics inheritance
  • 34. Formerly known as Bysted, Propeople, Blink Reaction, Chainbizz and Geekpolis TWIG inheritance result {# child.twig #} {% extends "base.twig" %} {% block post %} <article> <header>{{ post.title }}</header> <section>{{ post.text }}</section> </article> {% endblock %} Now, when rendering the child template
  • 35. Formerly known as Bysted, Propeople, Blink Reaction, Chainbizz and Geekpolis
  • 36. Formerly known as Bysted, Propeople, Blink Reaction, Chainbizz and Geekpolis TOOLS How to find stuff and debug
  • 37. Formerly known as Bysted, Propeople, Blink Reaction, Chainbizz and Geekpolis Where are the twig files?  In the system templates folder (/core/modules/system/templates) you’ll find more than 40 templates things like fields, nodes, pages, links.  All templates for the theme: [root]corethemesclassytemplates  They are separated in groups - layout - block - views - content - content-edit - field - navigation - dataset - forum - user - misc
  • 38. Formerly known as Bysted, Propeople, Blink Reaction, Chainbizz and Geekpolis Services.yml  If services.yml does not yet exist; copy default.services.yml and rename it to services.yml.  Locate the twig.config parameters in your services.yml and make changes there. twig.config: debug: true  Twig auto-reload auto_reload: true - Not recommended in production environments (Default: null).  Twig cache cache: false
  • 39. Formerly known as Bysted, Propeople, Blink Reaction, Chainbizz and Geekpolis SETTINGS.PHP  Copy: sites/settings.local.php  To: sites/default/settings.php  In Settings.php uncomment: if (file_exists(__DIR__ . '/settings.local.php')) { include __DIR__ . '/settings.local.php'; }
  • 40. Formerly known as Bysted, Propeople, Blink Reaction, Chainbizz and Geekpolis Firebug In firebug make sure that "Show Comments" is enabled:
  • 41. Formerly known as Bysted, Propeople, Blink Reaction, Chainbizz and Geekpolis Disable CSS cache and clear the cache!!!
  • 42. Formerly known as Bysted, Propeople, Blink Reaction, Chainbizz and Geekpolis After refresh the page
  • 43. Formerly known as Bysted, Propeople, Blink Reaction, Chainbizz and Geekpolis Another Way Devel module • Download Devel module • Install Devel + Kint • Enable Devel and Kint
  • 44. Formerly known as Bysted, Propeople, Blink Reaction, Chainbizz and Geekpolis Kint == Krumo for Drupal8 {{ kint(page) }}
  • 45. Formerly known as Bysted, Propeople, Blink Reaction, Chainbizz and Geekpolis
  • 46. Formerly known as Bysted, Propeople, Blink Reaction, Chainbizz and Geekpolis Resources and further reading • A brilliant blog post about D8 theming (Savas) • D8 theming guide (Sander) • YAML formatting (Symfony) • Intro to BEM (CSS Wizardry) • Adding assets to pages (drupal.org) • Twig documentation (Sensiolabs) • Drupal-specific Twig filters (drupal.org) • Twig coding standards (drupal.org) • Twig debugging and devel (drupalize.me)
  • 47. Formerly known as Bysted, Propeople, Blink Reaction, Chainbizz and Geekpolis Questions & Answers