SlideShare a Scribd company logo
DRUPAL 8 版型開發變⾰革
Chris Wu
TIME TO START WITH
DRUPAL 8
CODING
STANDARD
SMACSS & BEM
SMACSS - Scalable and Modular Architecture for CSS
Base
Layout
Module
State
Theme
BEM
.block__element--modifier
Block
Element
Modifier
BLOCK	
  	
  node	
  
	
  	
  __	
  ELEMENT	
  	
  title	
  	
  
	
  	
  __	
  ELEMENT	
  	
  content	
  
	
  	
  BLOCK	
  	
  field	
  
	
  	
  	
  	
  __	
  ELEMENT	
  label	
  
	
  	
  	
  	
  __	
  ELEMENT	
  items	
  
	
  	
  	
  	
  	
  	
  	
  -­‐-­‐	
  MODIFIER	
  	
  active	
  	
  	
  
BEM
NO CLASS
In Drupal Core
CLASSY
The New Core Theme
THEME LAYER
Classy
SparkBartik Seven
Drupal Core
THEME
structure changed
[theme].info.yml
[theme].theme
THEME - STRUCTURE CHANGED
/theme
[theme].libraries.yml
[theme].breakpoin.yml
name:	
  Foo	
  
type:	
  theme	
  
base	
  theme:	
  classy	
  
description:	
  'Foo	
  bar	
  theme'	
  
core:	
  8.x	
  
libraries:	
  
	
  	
  -­‐	
  foo/global-­‐styling	
  
	
  	
  -­‐	
  foo/bar	
  
regions:	
  
	
  	
  header:	
  Header	
  
	
  	
  primary_menu:	
  'Primary	
  menu'	
  
	
  	
  secondary_menu:	
  'Secondary	
  menu'
.INFO.YML
TEMPLATING
Template Suggestion
Pattern: node--[type|nodeid].tpl.php
1 node--nodeid.tpl.php
2 node--type.tpl.php
3 node.tpl.php
Pattern: node--[type|nodeid].html.twig
1 node--nodeid.html.twig
2 node--type.html.twig
3 node.html.twig
標題⽂文字
TWIG
no more theme_() and *.tpl.php
• 版型檔案不允許直接執⾏行	
  PHP	
  ,讓版型更為安全。	
  
• 版型開發者不必再學	
  PHP	
  
• 預設輸出時皆會	
  escape	
  ,減少	
  XSS	
  的可能性	
  
//	
  This	
  really	
  shouldn't	
  be	
  allowed	
  to	
  work,	
  and	
  it	
  won't	
  in	
  D8.	
  
<?php db_query('DROP TABLE {users}'); ?>
FROM PHPTEMPLATE TO TWIG
{{	
  }}	
  "say"	
  something	
  
{%	
  %}	
  "do"	
  something	
  
{#	
  #}	
  "write"	
  something
TWIG 101
– Drupal 8
{{	
  page.sidebar	
  }}	
  
{{	
  page['#type']	
  }}
Here are some example of filters from the Twig
engine.
{{ 'drupal' | length }} //return: 6
{{ 'drupal' | upper }} //return: DRUPAL
{{ 'drupal is awesome' | title }} //return: Drupal Is Awesome!
{{ '<a href="#">drupal is awesome!</a>'| striptags | capitalize }}
//return: Drupal is awesome!
FILTER
Drupal offers some additional filters.
Translation filters
PHP:	
  
<?php t('Content type'); ?>
TWIG:	
  
{{ 'Content type' | t }} //return: 內容類型
<a href="{{url('<front>')}}">{{'Home'|t}}</a> //return: ⾸首⾴頁
FILTER
{% for item in items %}
{% if not loop.last %}
<li{{ item.attributes }}>
{{ item.content }}
</li>
{% endif %}
{% endfor %}
DO SOMETHING
{%
set classes = [
'block',
'block-' ~ configuration.provider|clean_class,
'block-' ~ plugin_id|clean_class,
]
%}
<div{{ attributes.addClass(classes) }}>
{{ title_prefix }}
{% if label %}
<h2{{ title_attributes }}>{{ label }}</h2>
{% endif %}
{{ title_suffix }}
{% block content %}
<div{{ content_attributes.addClass('content') }}>
{{ content }}
</div>
{% endblock %}
</div>
{% BLOCK %}
{# block.html.twig #}
{# block--system-powered-by-block.html.twig #}
{% extends "block.html.twig" %}
{% block content %}
<div{{content_attributes.addClass('content')}}>
{{ content }}
</div>
{% endblock %}
{% BLOCK %}
#sites/default/settings.php:	
  	
  
$settings['container_yamls'][]	
  =	
  DRUPAL_ROOT.'/sites/development.services.yml';	
  
$settings['cache']['bins']['render']	
  =	
  'cache.backend.null';	
  
#sites/development.services.yml:	
  
parameters:	
  
	
  	
  twig.config:	
  
	
  	
  	
  	
  debug:	
  true
ENABLE DEBUGGING
PHP:	
  
<?php	
  var_dump();	
  ?>	
  
TWIG:	
  
{{	
  dump()	
  }}
DUMP VARIABLE
PHP	
  with	
  Devel	
  module:	
  
<?php	
  dpm();	
  ?>	
  
TWIG	
  with	
  Devel	
  +	
  Kint:	
  
{{	
  kint()	
  }}
BETTER DUMP
• Template Naming Convention: https://www.drupal.org/node/2354645
• The Drupal 8 Theming guide: http://d8.sqndr.com/new-theming-layer/README.html
• Deep dive anatomy drupal 8 theme: http://x-team.com/2015/04/deep-dive-anatomy-drupal-8-theming/
• D8Theming (with debug tut): http://savaslabs.com/2015/06/10/d8-theming-basics.html
REFERENCES
CHRIS WU
Cheers!
fb.me/amouro
@amourow

More Related Content

What's hot

Let's write secure Drupal code! - DrupalCamp Oslo, 2018
Let's write secure Drupal code! - DrupalCamp Oslo, 2018Let's write secure Drupal code! - DrupalCamp Oslo, 2018
Let's write secure Drupal code! - DrupalCamp Oslo, 2018
Balázs Tatár
 
Drupal 7 — Circle theme
Drupal 7 — Circle themeDrupal 7 — Circle theme
Drupal 7 — Circle theme
Kirill Borzov
 
Let's write secure Drupal code! - Drupal Camp Poland 2019
Let's write secure Drupal code! - Drupal Camp Poland 2019Let's write secure Drupal code! - Drupal Camp Poland 2019
Let's write secure Drupal code! - Drupal Camp Poland 2019
Balázs Tatár
 
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
Anne Tomasevich
 
Let's write secure drupal code! - Drupal Camp Pannonia 2019
Let's write secure drupal code! - Drupal Camp Pannonia 2019Let's write secure drupal code! - Drupal Camp Pannonia 2019
Let's write secure drupal code! - Drupal Camp Pannonia 2019
Balázs Tatár
 
Dc kyiv2010 jun_08
Dc kyiv2010 jun_08Dc kyiv2010 jun_08
Dc kyiv2010 jun_08
Andrii Podanenko
 
Drupal 8 introduction to theming
Drupal 8  introduction to themingDrupal 8  introduction to theming
Drupal 8 introduction to theming
Brahampal Singh
 
Laying the proper foundation for plugin and theme development
Laying the proper foundation for plugin and theme developmentLaying the proper foundation for plugin and theme development
Laying the proper foundation for plugin and theme developmentTammy Hart
 
18. images in symfony 4
18. images in symfony 418. images in symfony 4
18. images in symfony 4
Razvan Raducanu, PhD
 
PSD to a Drupal Theme (using a base theme)
PSD to a Drupal Theme (using a base theme)PSD to a Drupal Theme (using a base theme)
PSD to a Drupal Theme (using a base theme)
kuydigital
 
Working with WP_Query in WordPress
Working with WP_Query in WordPressWorking with WP_Query in WordPress
Working with WP_Query in WordPress
topher1kenobe
 
Jooctrine - Doctrine ORM in Joomla!
Jooctrine - Doctrine ORM in Joomla!Jooctrine - Doctrine ORM in Joomla!
Jooctrine - Doctrine ORM in Joomla!
Herman Peeren
 
Cake PHP 3 Presentaion
Cake PHP 3 PresentaionCake PHP 3 Presentaion
Cake PHP 3 Presentaion
glslarmenta
 
Apostrophe
ApostropheApostrophe
Apostrophe
tompunk
 
Extending the WordPress REST API - Josh Pollock
Extending the WordPress REST API - Josh PollockExtending the WordPress REST API - Josh Pollock
Extending the WordPress REST API - Josh Pollock
Caldera Labs
 
Let's write secure Drupal code! DUG Belgium - 08/08/2019
Let's write secure Drupal code! DUG Belgium - 08/08/2019Let's write secure Drupal code! DUG Belgium - 08/08/2019
Let's write secure Drupal code! DUG Belgium - 08/08/2019
Balázs Tatár
 
Drupal 8: Entities
Drupal 8: EntitiesDrupal 8: Entities
Drupal 8: Entities
drubb
 
Views Style Plugins
Views Style PluginsViews Style Plugins
Views Style Plugins
mwrather
 
The Render API in Drupal 7
The Render API in Drupal 7The Render API in Drupal 7
The Render API in Drupal 7
frandoh
 
Drupal Theme Development
Drupal Theme DevelopmentDrupal Theme Development
Drupal Theme Development
Web Development Montreal
 

What's hot (20)

Let's write secure Drupal code! - DrupalCamp Oslo, 2018
Let's write secure Drupal code! - DrupalCamp Oslo, 2018Let's write secure Drupal code! - DrupalCamp Oslo, 2018
Let's write secure Drupal code! - DrupalCamp Oslo, 2018
 
Drupal 7 — Circle theme
Drupal 7 — Circle themeDrupal 7 — Circle theme
Drupal 7 — Circle theme
 
Let's write secure Drupal code! - Drupal Camp Poland 2019
Let's write secure Drupal code! - Drupal Camp Poland 2019Let's write secure Drupal code! - Drupal Camp Poland 2019
Let's write secure Drupal code! - Drupal Camp Poland 2019
 
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
 
Let's write secure drupal code! - Drupal Camp Pannonia 2019
Let's write secure drupal code! - Drupal Camp Pannonia 2019Let's write secure drupal code! - Drupal Camp Pannonia 2019
Let's write secure drupal code! - Drupal Camp Pannonia 2019
 
Dc kyiv2010 jun_08
Dc kyiv2010 jun_08Dc kyiv2010 jun_08
Dc kyiv2010 jun_08
 
Drupal 8 introduction to theming
Drupal 8  introduction to themingDrupal 8  introduction to theming
Drupal 8 introduction to theming
 
Laying the proper foundation for plugin and theme development
Laying the proper foundation for plugin and theme developmentLaying the proper foundation for plugin and theme development
Laying the proper foundation for plugin and theme development
 
18. images in symfony 4
18. images in symfony 418. images in symfony 4
18. images in symfony 4
 
PSD to a Drupal Theme (using a base theme)
PSD to a Drupal Theme (using a base theme)PSD to a Drupal Theme (using a base theme)
PSD to a Drupal Theme (using a base theme)
 
Working with WP_Query in WordPress
Working with WP_Query in WordPressWorking with WP_Query in WordPress
Working with WP_Query in WordPress
 
Jooctrine - Doctrine ORM in Joomla!
Jooctrine - Doctrine ORM in Joomla!Jooctrine - Doctrine ORM in Joomla!
Jooctrine - Doctrine ORM in Joomla!
 
Cake PHP 3 Presentaion
Cake PHP 3 PresentaionCake PHP 3 Presentaion
Cake PHP 3 Presentaion
 
Apostrophe
ApostropheApostrophe
Apostrophe
 
Extending the WordPress REST API - Josh Pollock
Extending the WordPress REST API - Josh PollockExtending the WordPress REST API - Josh Pollock
Extending the WordPress REST API - Josh Pollock
 
Let's write secure Drupal code! DUG Belgium - 08/08/2019
Let's write secure Drupal code! DUG Belgium - 08/08/2019Let's write secure Drupal code! DUG Belgium - 08/08/2019
Let's write secure Drupal code! DUG Belgium - 08/08/2019
 
Drupal 8: Entities
Drupal 8: EntitiesDrupal 8: Entities
Drupal 8: Entities
 
Views Style Plugins
Views Style PluginsViews Style Plugins
Views Style Plugins
 
The Render API in Drupal 7
The Render API in Drupal 7The Render API in Drupal 7
The Render API in Drupal 7
 
Drupal Theme Development
Drupal Theme DevelopmentDrupal Theme Development
Drupal Theme Development
 

Viewers also liked

план мероприятий по году литературы мбдоу 231
план мероприятий по году литературы  мбдоу 231план мероприятий по году литературы  мбдоу 231
план мероприятий по году литературы мбдоу 231
virtualtaganrog
 
2017_03_20 СКРЕБЕЦЬ Ю.Ю. - заступник головного лікаря з хірургічної служби
2017_03_20 СКРЕБЕЦЬ Ю.Ю. - заступник головного лікаря з хірургічної служби2017_03_20 СКРЕБЕЦЬ Ю.Ю. - заступник головного лікаря з хірургічної служби
2017_03_20 СКРЕБЕЦЬ Ю.Ю. - заступник головного лікаря з хірургічної служби
Дніпропетровська обласна клінічна лікарня ім. І.І. Мечникова
 
индивидуальная работа с детьми в подготовительной группе
индивидуальная работа с детьми в подготовительной группеиндивидуальная работа с детьми в подготовительной группе
индивидуальная работа с детьми в подготовительной группе
virtualtaganrog
 
50 jawapan ulasan
50 jawapan ulasan50 jawapan ulasan
50 jawapan ulasan
gunavathy
 
Mi autografía artística
Mi autografía artísticaMi autografía artística
Mi autografía artística
MAYRA GONZALEZ
 
Шкатулка качественных задач
Шкатулка качественных задачШкатулка качественных задач
Шкатулка качественных задач
sveta7940
 
Внеклассное мероприятие"Открытая лаборатория"
Внеклассное мероприятие"Открытая лаборатория"Внеклассное мероприятие"Открытая лаборатория"
Внеклассное мероприятие"Открытая лаборатория"
sveta7940
 
Unit 4. natural sciences.
Unit 4. natural sciences.Unit 4. natural sciences.
Unit 4. natural sciences.
Marcos Rodríguez Ucedo
 
Theories career development counseling
Theories career development counselingTheories career development counseling
Theories career development counseling
Maheshbabu N
 
2. toxicología capítulo 2
2. toxicología   capítulo 22. toxicología   capítulo 2
2. toxicología capítulo 2
adn estela martin
 
Digital media market_brief_2017_03
Digital media market_brief_2017_03Digital media market_brief_2017_03
Digital media market_brief_2017_03
Nasmedia
 
FabZat Publisher Presentation 2016
FabZat Publisher Presentation 2016FabZat Publisher Presentation 2016
FabZat Publisher Presentation 2016
Taylor Cavale
 
Searching for reliable business information: free versus fee
Searching for reliable business information: free versus feeSearching for reliable business information: free versus fee
Searching for reliable business information: free versus fee
voginip
 
1. perspectivas teóricas aprendizaje conductual, cognitiva, TAS de Bandura
1. perspectivas teóricas aprendizaje conductual, cognitiva, TAS de Bandura1. perspectivas teóricas aprendizaje conductual, cognitiva, TAS de Bandura
1. perspectivas teóricas aprendizaje conductual, cognitiva, TAS de Bandura
Gerardo Viau Mollinedo
 
How to run more creative events that add value.
How to run more creative events that add value.How to run more creative events that add value.
How to run more creative events that add value.
William Thomson
 

Viewers also liked (15)

план мероприятий по году литературы мбдоу 231
план мероприятий по году литературы  мбдоу 231план мероприятий по году литературы  мбдоу 231
план мероприятий по году литературы мбдоу 231
 
2017_03_20 СКРЕБЕЦЬ Ю.Ю. - заступник головного лікаря з хірургічної служби
2017_03_20 СКРЕБЕЦЬ Ю.Ю. - заступник головного лікаря з хірургічної служби2017_03_20 СКРЕБЕЦЬ Ю.Ю. - заступник головного лікаря з хірургічної служби
2017_03_20 СКРЕБЕЦЬ Ю.Ю. - заступник головного лікаря з хірургічної служби
 
индивидуальная работа с детьми в подготовительной группе
индивидуальная работа с детьми в подготовительной группеиндивидуальная работа с детьми в подготовительной группе
индивидуальная работа с детьми в подготовительной группе
 
50 jawapan ulasan
50 jawapan ulasan50 jawapan ulasan
50 jawapan ulasan
 
Mi autografía artística
Mi autografía artísticaMi autografía artística
Mi autografía artística
 
Шкатулка качественных задач
Шкатулка качественных задачШкатулка качественных задач
Шкатулка качественных задач
 
Внеклассное мероприятие"Открытая лаборатория"
Внеклассное мероприятие"Открытая лаборатория"Внеклассное мероприятие"Открытая лаборатория"
Внеклассное мероприятие"Открытая лаборатория"
 
Unit 4. natural sciences.
Unit 4. natural sciences.Unit 4. natural sciences.
Unit 4. natural sciences.
 
Theories career development counseling
Theories career development counselingTheories career development counseling
Theories career development counseling
 
2. toxicología capítulo 2
2. toxicología   capítulo 22. toxicología   capítulo 2
2. toxicología capítulo 2
 
Digital media market_brief_2017_03
Digital media market_brief_2017_03Digital media market_brief_2017_03
Digital media market_brief_2017_03
 
FabZat Publisher Presentation 2016
FabZat Publisher Presentation 2016FabZat Publisher Presentation 2016
FabZat Publisher Presentation 2016
 
Searching for reliable business information: free versus fee
Searching for reliable business information: free versus feeSearching for reliable business information: free versus fee
Searching for reliable business information: free versus fee
 
1. perspectivas teóricas aprendizaje conductual, cognitiva, TAS de Bandura
1. perspectivas teóricas aprendizaje conductual, cognitiva, TAS de Bandura1. perspectivas teóricas aprendizaje conductual, cognitiva, TAS de Bandura
1. perspectivas teóricas aprendizaje conductual, cognitiva, TAS de Bandura
 
How to run more creative events that add value.
How to run more creative events that add value.How to run more creative events that add value.
How to run more creative events that add value.
 

Similar to Drupal 8 版型開發變革

Drupal theming
Drupal themingDrupal theming
Drupal theming
Philip Norton
 
Building Drupal 6 Theme
Building Drupal 6 ThemeBuilding Drupal 6 Theme
Building Drupal 6 Theme
Gaurav Khambhala
 
Drupal theme development
Drupal theme developmentDrupal theme development
Drupal theme development
Fortune Innovations Dublin
 
Drupal Best Practices
Drupal Best PracticesDrupal Best Practices
Drupal Best Practices
manugoel2003
 
Drupal 8: frontend development
Drupal 8: frontend developmentDrupal 8: frontend development
Drupal 8: frontend development
sparkfabrik
 
The Flexibility of Drupal 8 | DCNLights 2017
The Flexibility of Drupal 8 | DCNLights 2017The Flexibility of Drupal 8 | DCNLights 2017
The Flexibility of Drupal 8 | DCNLights 2017
Michael Miles
 
Theming tips and tricks
Theming tips and tricksTheming tips and tricks
Theming tips and tricksaaroncouch
 
Drupal 8 - Corso frontend development
Drupal 8 - Corso frontend developmentDrupal 8 - Corso frontend development
Drupal 8 - Corso frontend development
sparkfabrik
 
Drupal
DrupalDrupal
Drupal
tnhomestead
 
Changes to Drupal Themes in version 7 (part 1)
Changes to Drupal Themes in version 7 (part 1)Changes to Drupal Themes in version 7 (part 1)
Changes to Drupal Themes in version 7 (part 1)
Chris Charlton
 
Drupal 8: What's new? Anton Shubkin
Drupal 8: What's new? Anton ShubkinDrupal 8: What's new? Anton Shubkin
Drupal 8: What's new? Anton ShubkinADCI Solutions
 
D7 theming what's new - London
D7 theming what's new - LondonD7 theming what's new - London
D7 theming what's new - London
Marek Sotak
 
Twig for Drupal @ Frontendunited Amsterdam 2012
Twig for Drupal @ Frontendunited Amsterdam 2012Twig for Drupal @ Frontendunited Amsterdam 2012
Twig for Drupal @ Frontendunited Amsterdam 2012
Rene Bakx
 
Drupal Themes
Drupal ThemesDrupal Themes
Drupal Themes
akosh
 
Drupal7 themeing changes and inheritence
Drupal7 themeing changes and inheritenceDrupal7 themeing changes and inheritence
Drupal7 themeing changes and inheritence
Aimee Maree Forsstrom
 
Drupal 7 Theming - Behind the scenes
Drupal 7 Theming - Behind the scenes Drupal 7 Theming - Behind the scenes
Drupal 7 Theming - Behind the scenes
ramakesavan
 
Drupal 8 Every Day: An Intro to Developing With Drupal 8
Drupal 8 Every Day: An Intro to Developing With Drupal 8Drupal 8 Every Day: An Intro to Developing With Drupal 8
Drupal 8 Every Day: An Intro to Developing With Drupal 8
Acquia
 
Drupal Module Development - OSI Days 2010
Drupal Module Development - OSI Days 2010Drupal Module Development - OSI Days 2010
Drupal Module Development - OSI Days 2010
Siva Epari
 
Demystifying drupal 7 theming
Demystifying drupal 7 themingDemystifying drupal 7 theming
Demystifying drupal 7 theming
Anthony Ogbonna
 
Theme Kickstart
Theme KickstartTheme Kickstart
Theme Kickstart
Peter
 

Similar to Drupal 8 版型開發變革 (20)

Drupal theming
Drupal themingDrupal theming
Drupal theming
 
Building Drupal 6 Theme
Building Drupal 6 ThemeBuilding Drupal 6 Theme
Building Drupal 6 Theme
 
Drupal theme development
Drupal theme developmentDrupal theme development
Drupal theme development
 
Drupal Best Practices
Drupal Best PracticesDrupal Best Practices
Drupal Best Practices
 
Drupal 8: frontend development
Drupal 8: frontend developmentDrupal 8: frontend development
Drupal 8: frontend development
 
The Flexibility of Drupal 8 | DCNLights 2017
The Flexibility of Drupal 8 | DCNLights 2017The Flexibility of Drupal 8 | DCNLights 2017
The Flexibility of Drupal 8 | DCNLights 2017
 
Theming tips and tricks
Theming tips and tricksTheming tips and tricks
Theming tips and tricks
 
Drupal 8 - Corso frontend development
Drupal 8 - Corso frontend developmentDrupal 8 - Corso frontend development
Drupal 8 - Corso frontend development
 
Drupal
DrupalDrupal
Drupal
 
Changes to Drupal Themes in version 7 (part 1)
Changes to Drupal Themes in version 7 (part 1)Changes to Drupal Themes in version 7 (part 1)
Changes to Drupal Themes in version 7 (part 1)
 
Drupal 8: What's new? Anton Shubkin
Drupal 8: What's new? Anton ShubkinDrupal 8: What's new? Anton Shubkin
Drupal 8: What's new? Anton Shubkin
 
D7 theming what's new - London
D7 theming what's new - LondonD7 theming what's new - London
D7 theming what's new - London
 
Twig for Drupal @ Frontendunited Amsterdam 2012
Twig for Drupal @ Frontendunited Amsterdam 2012Twig for Drupal @ Frontendunited Amsterdam 2012
Twig for Drupal @ Frontendunited Amsterdam 2012
 
Drupal Themes
Drupal ThemesDrupal Themes
Drupal Themes
 
Drupal7 themeing changes and inheritence
Drupal7 themeing changes and inheritenceDrupal7 themeing changes and inheritence
Drupal7 themeing changes and inheritence
 
Drupal 7 Theming - Behind the scenes
Drupal 7 Theming - Behind the scenes Drupal 7 Theming - Behind the scenes
Drupal 7 Theming - Behind the scenes
 
Drupal 8 Every Day: An Intro to Developing With Drupal 8
Drupal 8 Every Day: An Intro to Developing With Drupal 8Drupal 8 Every Day: An Intro to Developing With Drupal 8
Drupal 8 Every Day: An Intro to Developing With Drupal 8
 
Drupal Module Development - OSI Days 2010
Drupal Module Development - OSI Days 2010Drupal Module Development - OSI Days 2010
Drupal Module Development - OSI Days 2010
 
Demystifying drupal 7 theming
Demystifying drupal 7 themingDemystifying drupal 7 theming
Demystifying drupal 7 theming
 
Theme Kickstart
Theme KickstartTheme Kickstart
Theme Kickstart
 

More from Chris Wu

Effective Designer - 有效率的設計師
Effective Designer - 有效率的設計師Effective Designer - 有效率的設計師
Effective Designer - 有效率的設計師
Chris Wu
 
Building E-Commerce Content Marketing Site for Fashion Industry - Drupal Camp...
Building E-Commerce Content Marketing Site for Fashion Industry - Drupal Camp...Building E-Commerce Content Marketing Site for Fashion Industry - Drupal Camp...
Building E-Commerce Content Marketing Site for Fashion Industry - Drupal Camp...
Chris Wu
 
MRT Express 極速北捷(UI/UX Designers' Night)
MRT Express 極速北捷(UI/UX Designers' Night)MRT Express 極速北捷(UI/UX Designers' Night)
MRT Express 極速北捷(UI/UX Designers' Night)
Chris Wu
 
從技術角度看 RWD - Technical Approaches to RWD
從技術角度看 RWD - Technical Approaches to RWD從技術角度看 RWD - Technical Approaches to RWD
從技術角度看 RWD - Technical Approaches to RWD
Chris Wu
 
Responsive design on drupal
Responsive design on drupalResponsive design on drupal
Responsive design on drupal
Chris Wu
 
那些年,我們一起搞的金流
那些年,我們一起搞的金流那些年,我們一起搞的金流
那些年,我們一起搞的金流
Chris Wu
 
DrupalTaiwan.org 社群簡介
DrupalTaiwan.org 社群簡介DrupalTaiwan.org 社群簡介
DrupalTaiwan.org 社群簡介Chris Wu
 
Drupalcamp Taipei 2012 說明會
Drupalcamp Taipei 2012 說明會Drupalcamp Taipei 2012 說明會
Drupalcamp Taipei 2012 說明會
Chris Wu
 
Drupal 版型設計 - 瞭解版型程式
Drupal 版型設計 - 瞭解版型程式Drupal 版型設計 - 瞭解版型程式
Drupal 版型設計 - 瞭解版型程式Chris Wu
 

More from Chris Wu (9)

Effective Designer - 有效率的設計師
Effective Designer - 有效率的設計師Effective Designer - 有效率的設計師
Effective Designer - 有效率的設計師
 
Building E-Commerce Content Marketing Site for Fashion Industry - Drupal Camp...
Building E-Commerce Content Marketing Site for Fashion Industry - Drupal Camp...Building E-Commerce Content Marketing Site for Fashion Industry - Drupal Camp...
Building E-Commerce Content Marketing Site for Fashion Industry - Drupal Camp...
 
MRT Express 極速北捷(UI/UX Designers' Night)
MRT Express 極速北捷(UI/UX Designers' Night)MRT Express 極速北捷(UI/UX Designers' Night)
MRT Express 極速北捷(UI/UX Designers' Night)
 
從技術角度看 RWD - Technical Approaches to RWD
從技術角度看 RWD - Technical Approaches to RWD從技術角度看 RWD - Technical Approaches to RWD
從技術角度看 RWD - Technical Approaches to RWD
 
Responsive design on drupal
Responsive design on drupalResponsive design on drupal
Responsive design on drupal
 
那些年,我們一起搞的金流
那些年,我們一起搞的金流那些年,我們一起搞的金流
那些年,我們一起搞的金流
 
DrupalTaiwan.org 社群簡介
DrupalTaiwan.org 社群簡介DrupalTaiwan.org 社群簡介
DrupalTaiwan.org 社群簡介
 
Drupalcamp Taipei 2012 說明會
Drupalcamp Taipei 2012 說明會Drupalcamp Taipei 2012 說明會
Drupalcamp Taipei 2012 說明會
 
Drupal 版型設計 - 瞭解版型程式
Drupal 版型設計 - 瞭解版型程式Drupal 版型設計 - 瞭解版型程式
Drupal 版型設計 - 瞭解版型程式
 

Recently uploaded

RESUME BUILDER APPLICATION Project for students
RESUME BUILDER APPLICATION Project for studentsRESUME BUILDER APPLICATION Project for students
RESUME BUILDER APPLICATION Project for students
KAMESHS29
 
Microsoft - Power Platform_G.Aspiotis.pdf
Microsoft - Power Platform_G.Aspiotis.pdfMicrosoft - Power Platform_G.Aspiotis.pdf
Microsoft - Power Platform_G.Aspiotis.pdf
Uni Systems S.M.S.A.
 
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
Neo4j
 
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdfObservability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Paige Cruz
 
Uni Systems Copilot event_05062024_C.Vlachos.pdf
Uni Systems Copilot event_05062024_C.Vlachos.pdfUni Systems Copilot event_05062024_C.Vlachos.pdf
Uni Systems Copilot event_05062024_C.Vlachos.pdf
Uni Systems S.M.S.A.
 
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
James Anderson
 
Epistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI supportEpistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI support
Alan Dix
 
The Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and SalesThe Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and Sales
Laura Byrne
 
Artificial Intelligence for XMLDevelopment
Artificial Intelligence for XMLDevelopmentArtificial Intelligence for XMLDevelopment
Artificial Intelligence for XMLDevelopment
Octavian Nadolu
 
20240607 QFM018 Elixir Reading List May 2024
20240607 QFM018 Elixir Reading List May 202420240607 QFM018 Elixir Reading List May 2024
20240607 QFM018 Elixir Reading List May 2024
Matthew Sinclair
 
GraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge GraphGraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge Graph
Guy Korland
 
Mind map of terminologies used in context of Generative AI
Mind map of terminologies used in context of Generative AIMind map of terminologies used in context of Generative AI
Mind map of terminologies used in context of Generative AI
Kumud Singh
 
PCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase TeamPCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase Team
ControlCase
 
Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !
KatiaHIMEUR1
 
Monitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR EventsMonitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR Events
Ana-Maria Mihalceanu
 
Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...
Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...
Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...
James Anderson
 
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
DanBrown980551
 
Enchancing adoption of Open Source Libraries. A case study on Albumentations.AI
Enchancing adoption of Open Source Libraries. A case study on Albumentations.AIEnchancing adoption of Open Source Libraries. A case study on Albumentations.AI
Enchancing adoption of Open Source Libraries. A case study on Albumentations.AI
Vladimir Iglovikov, Ph.D.
 
GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...
GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...
GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...
Neo4j
 
Large Language Model (LLM) and it’s Geospatial Applications
Large Language Model (LLM) and it’s Geospatial ApplicationsLarge Language Model (LLM) and it’s Geospatial Applications
Large Language Model (LLM) and it’s Geospatial Applications
Rohit Gautam
 

Recently uploaded (20)

RESUME BUILDER APPLICATION Project for students
RESUME BUILDER APPLICATION Project for studentsRESUME BUILDER APPLICATION Project for students
RESUME BUILDER APPLICATION Project for students
 
Microsoft - Power Platform_G.Aspiotis.pdf
Microsoft - Power Platform_G.Aspiotis.pdfMicrosoft - Power Platform_G.Aspiotis.pdf
Microsoft - Power Platform_G.Aspiotis.pdf
 
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
 
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdfObservability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
 
Uni Systems Copilot event_05062024_C.Vlachos.pdf
Uni Systems Copilot event_05062024_C.Vlachos.pdfUni Systems Copilot event_05062024_C.Vlachos.pdf
Uni Systems Copilot event_05062024_C.Vlachos.pdf
 
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
 
Epistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI supportEpistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI support
 
The Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and SalesThe Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and Sales
 
Artificial Intelligence for XMLDevelopment
Artificial Intelligence for XMLDevelopmentArtificial Intelligence for XMLDevelopment
Artificial Intelligence for XMLDevelopment
 
20240607 QFM018 Elixir Reading List May 2024
20240607 QFM018 Elixir Reading List May 202420240607 QFM018 Elixir Reading List May 2024
20240607 QFM018 Elixir Reading List May 2024
 
GraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge GraphGraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge Graph
 
Mind map of terminologies used in context of Generative AI
Mind map of terminologies used in context of Generative AIMind map of terminologies used in context of Generative AI
Mind map of terminologies used in context of Generative AI
 
PCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase TeamPCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase Team
 
Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !
 
Monitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR EventsMonitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR Events
 
Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...
Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...
Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...
 
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
 
Enchancing adoption of Open Source Libraries. A case study on Albumentations.AI
Enchancing adoption of Open Source Libraries. A case study on Albumentations.AIEnchancing adoption of Open Source Libraries. A case study on Albumentations.AI
Enchancing adoption of Open Source Libraries. A case study on Albumentations.AI
 
GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...
GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...
GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...
 
Large Language Model (LLM) and it’s Geospatial Applications
Large Language Model (LLM) and it’s Geospatial ApplicationsLarge Language Model (LLM) and it’s Geospatial Applications
Large Language Model (LLM) and it’s Geospatial Applications
 

Drupal 8 版型開發變革

  • 2. TIME TO START WITH DRUPAL 8
  • 4. SMACSS - Scalable and Modular Architecture for CSS Base Layout Module State Theme
  • 6. BLOCK    node      __  ELEMENT    title        __  ELEMENT    content      BLOCK    field          __  ELEMENT  label          __  ELEMENT  items                -­‐-­‐  MODIFIER    active       BEM
  • 11. [theme].info.yml [theme].theme THEME - STRUCTURE CHANGED /theme [theme].libraries.yml [theme].breakpoin.yml
  • 12. name:  Foo   type:  theme   base  theme:  classy   description:  'Foo  bar  theme'   core:  8.x   libraries:      -­‐  foo/global-­‐styling      -­‐  foo/bar   regions:      header:  Header      primary_menu:  'Primary  menu'      secondary_menu:  'Secondary  menu' .INFO.YML
  • 14. Template Suggestion Pattern: node--[type|nodeid].tpl.php 1 node--nodeid.tpl.php 2 node--type.tpl.php 3 node.tpl.php Pattern: node--[type|nodeid].html.twig 1 node--nodeid.html.twig 2 node--type.html.twig 3 node.html.twig 標題⽂文字
  • 15. TWIG no more theme_() and *.tpl.php
  • 16. • 版型檔案不允許直接執⾏行  PHP  ,讓版型更為安全。   • 版型開發者不必再學  PHP   • 預設輸出時皆會  escape  ,減少  XSS  的可能性   //  This  really  shouldn't  be  allowed  to  work,  and  it  won't  in  D8.   <?php db_query('DROP TABLE {users}'); ?> FROM PHPTEMPLATE TO TWIG
  • 17. {{  }}  "say"  something   {%  %}  "do"  something   {#  #}  "write"  something TWIG 101
  • 18. – Drupal 8 {{  page.sidebar  }}   {{  page['#type']  }}
  • 19. Here are some example of filters from the Twig engine. {{ 'drupal' | length }} //return: 6 {{ 'drupal' | upper }} //return: DRUPAL {{ 'drupal is awesome' | title }} //return: Drupal Is Awesome! {{ '<a href="#">drupal is awesome!</a>'| striptags | capitalize }} //return: Drupal is awesome! FILTER
  • 20. Drupal offers some additional filters. Translation filters PHP:   <?php t('Content type'); ?> TWIG:   {{ 'Content type' | t }} //return: 內容類型 <a href="{{url('<front>')}}">{{'Home'|t}}</a> //return: ⾸首⾴頁 FILTER
  • 21. {% for item in items %} {% if not loop.last %} <li{{ item.attributes }}> {{ item.content }} </li> {% endif %} {% endfor %} DO SOMETHING
  • 22. {% set classes = [ 'block', 'block-' ~ configuration.provider|clean_class, 'block-' ~ plugin_id|clean_class, ] %} <div{{ attributes.addClass(classes) }}> {{ title_prefix }} {% if label %} <h2{{ title_attributes }}>{{ label }}</h2> {% endif %} {{ title_suffix }} {% block content %} <div{{ content_attributes.addClass('content') }}> {{ content }} </div> {% endblock %} </div> {% BLOCK %} {# block.html.twig #}
  • 23. {# block--system-powered-by-block.html.twig #} {% extends "block.html.twig" %} {% block content %} <div{{content_attributes.addClass('content')}}> {{ content }} </div> {% endblock %} {% BLOCK %}
  • 24.
  • 25. #sites/default/settings.php:     $settings['container_yamls'][]  =  DRUPAL_ROOT.'/sites/development.services.yml';   $settings['cache']['bins']['render']  =  'cache.backend.null';   #sites/development.services.yml:   parameters:      twig.config:          debug:  true ENABLE DEBUGGING
  • 26. PHP:   <?php  var_dump();  ?>   TWIG:   {{  dump()  }} DUMP VARIABLE
  • 27. PHP  with  Devel  module:   <?php  dpm();  ?>   TWIG  with  Devel  +  Kint:   {{  kint()  }} BETTER DUMP
  • 28. • Template Naming Convention: https://www.drupal.org/node/2354645 • The Drupal 8 Theming guide: http://d8.sqndr.com/new-theming-layer/README.html • Deep dive anatomy drupal 8 theme: http://x-team.com/2015/04/deep-dive-anatomy-drupal-8-theming/ • D8Theming (with debug tut): http://savaslabs.com/2015/06/10/d8-theming-basics.html REFERENCES