SlideShare ist ein Scribd-Unternehmen logo
1 von 34
Advanced Theming
           Digging deeper into Drupal’s presentation layer




http://knowclassic.com
Who am I?

          •    Thomas Lattimore, often know as @tlattimore

          •    Front-End Developer for Classic Graphics

          •    Drupal enthusiast!

              •   See what I do: drupal.org/user/624754




http://knowclassic.com
This Session
•   Assumes you have understanding of Drupal theming

    •   The basic anatomy of a theme including .info,
        template.php, .tpl's, & how sub-theming works.

•   ... and you can write own CSS/HTML with some
    understanding of PHP

•   You want to do more than Drupal's default output

    •   This can include markup, attributes, or data
        formatting
What is ‘advanced’
   theming?
Overrides!
                What Drupal theming is made of



•   CSS

•   .tpl.php

•   Function(s) - in template.php
Which method do I use?
Which method do I use?
Which method do I use?
Which method do I use?



 Answer:
Which method do I use?



         It depends on your process
 Answer:
         and need
Use CSS
Use CSS
•   If the markup (elements, classes, ids, etc) are
    already in place.
Use CSS
•   If the markup (elements, classes, ids, etc) are
    already in place.
Use CSS
•   If the markup (elements, classes, ids, etc) are
    already in place.
Use CSS
•   If the markup (elements, classes, ids, etc) are
    already in place.
Use CSS
•   If the markup (elements, classes, ids, etc) are
    already in place.
Use CSS
•   If the markup (elements, classes, ids, etc) are
    already in place.
Use CSS
•   If the markup (elements, classes, ids, etc) are
    already in place.




• For better or for worse,
Drupal has LOTS of selectors
Use them!
Tpl Override
•   If the markup and or attribute you want to override is
    already in a .tpl file




•   Template suggestion doc page:
    http://drupal.org/node/1089656
Function Overrides
Function Overrides
•   You need to actually dig into the data (stuff inside the
    $vars) before it hits the .tpl file, these functions go in
    template.php
Function Overrides
•   You need to actually dig into the data (stuff inside the
    $vars) before it hits the .tpl file, these functions go in
    template.php

•   This includes (but is not exclusive to):
Function Overrides
•   You need to actually dig into the data (stuff inside the
    $vars) before it hits the .tpl file, these functions go in
    template.php

•   This includes (but is not exclusive to):

    •   hook_*_alter()
Function Overrides
•   You need to actually dig into the data (stuff inside the
    $vars) before it hits the .tpl file, these functions go in
    template.php

•   This includes (but is not exclusive to):

    •   hook_*_alter()

    •   template_preprocess()
Function Overrides
•   You need to actually dig into the data (stuff inside the
    $vars) before it hits the .tpl file, these functions go in
    template.php

•   This includes (but is not exclusive to):

    •   hook_*_alter()

    •   template_preprocess()

    •   theme_hook()
Function Overrides
Function Overrides



This is where things really get fun!
      (and largely what we’ll cover today)
Common alter hooks

•   hook_page_alter()

    •   A HUGE array of all the regions on the page

•   hook_form_alter()

    •   Alter all sorts of form goodies

•   hook_css_alter()

    •   Move around the order in which css is printed
template_preprocess()
template_preprocess()
•   Includes: template_preprocess(),
    template_preprocess_page(),
    template_preprocess_node(), and more...

•   template_preprocess()

    •   Add and modify variables before they hit there
        corresponding .tpl

    •   Add tpl suggestions via
        ‘theme_hook_suggestions’ array
template_preprocess()
 •   Includes: template_preprocess(),
     template_preprocess_page(),
     template_preprocess_node(), and more...

 •   template_preprocess()

     •   Add and modify variables before they hit there
         corresponding .tpl

     •   Add tpl suggestions via
         ‘theme_hook_suggestions’ array

Basically, generates the themable output
Today we are....
•   Sub-theming bartik (for simplicities sake)

•   Using devel + devel_themer
Enough talk! Lets code

Weitere ähnliche Inhalte

Was ist angesagt?

Absolute Beginners Guide to Drupal
Absolute Beginners Guide to DrupalAbsolute Beginners Guide to Drupal
Absolute Beginners Guide to DrupalRod Martin
 
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
 
Grok Drupal (7) Theming - 2011 Feb update
Grok Drupal (7) Theming - 2011 Feb updateGrok Drupal (7) Theming - 2011 Feb update
Grok Drupal (7) Theming - 2011 Feb updateLaura Scott
 
New Adventures in Drupal Theming
New Adventures in Drupal ThemingNew Adventures in Drupal Theming
New Adventures in Drupal ThemingJohn Albin Wilkins
 
WordPress Themes 101 - dotEduGuru Summit 2013
WordPress Themes 101 - dotEduGuru Summit 2013WordPress Themes 101 - dotEduGuru Summit 2013
WordPress Themes 101 - dotEduGuru Summit 2013Curtiss Grymala
 
Drupal 8 introduction to theming
Drupal 8  introduction to themingDrupal 8  introduction to theming
Drupal 8 introduction to themingBrahampal Singh
 
Grok Drupal (7) Theming
Grok Drupal (7) ThemingGrok Drupal (7) Theming
Grok Drupal (7) ThemingPINGV
 
Banishing Loops with Functional Programming in PHP
Banishing Loops with Functional Programming in PHPBanishing Loops with Functional Programming in PHP
Banishing Loops with Functional Programming in PHPDavid Hayes
 
DSpace 4.2 XMLUI Theming
DSpace 4.2 XMLUI ThemingDSpace 4.2 XMLUI Theming
DSpace 4.2 XMLUI ThemingDuraSpace
 

Was ist angesagt? (10)

Absolute Beginners Guide to Drupal
Absolute Beginners Guide to DrupalAbsolute Beginners Guide to Drupal
Absolute Beginners Guide to Drupal
 
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
 
Grok Drupal (7) Theming - 2011 Feb update
Grok Drupal (7) Theming - 2011 Feb updateGrok Drupal (7) Theming - 2011 Feb update
Grok Drupal (7) Theming - 2011 Feb update
 
New Adventures in Drupal Theming
New Adventures in Drupal ThemingNew Adventures in Drupal Theming
New Adventures in Drupal Theming
 
WordPress Themes 101 - dotEduGuru Summit 2013
WordPress Themes 101 - dotEduGuru Summit 2013WordPress Themes 101 - dotEduGuru Summit 2013
WordPress Themes 101 - dotEduGuru Summit 2013
 
Drupal 8 introduction to theming
Drupal 8  introduction to themingDrupal 8  introduction to theming
Drupal 8 introduction to theming
 
Grok Drupal (7) Theming
Grok Drupal (7) ThemingGrok Drupal (7) Theming
Grok Drupal (7) Theming
 
Banishing Loops with Functional Programming in PHP
Banishing Loops with Functional Programming in PHPBanishing Loops with Functional Programming in PHP
Banishing Loops with Functional Programming in PHP
 
Nanocon Taiwan
Nanocon TaiwanNanocon Taiwan
Nanocon Taiwan
 
DSpace 4.2 XMLUI Theming
DSpace 4.2 XMLUI ThemingDSpace 4.2 XMLUI Theming
DSpace 4.2 XMLUI Theming
 

Andere mochten auch

Moeller bosc2010 debian_taverna
Moeller bosc2010 debian_tavernaMoeller bosc2010 debian_taverna
Moeller bosc2010 debian_tavernaBOSC 2010
 
Moderaterna - Måndagens frukostseminarie i Almedalen -
Moderaterna - Måndagens frukostseminarie i Almedalen - Moderaterna - Måndagens frukostseminarie i Almedalen -
Moderaterna - Måndagens frukostseminarie i Almedalen - Infopaq Sverige
 
안드로이드스터디 2
안드로이드스터디 2안드로이드스터디 2
안드로이드스터디 2jangpd007
 
אשנב מצגת הורים- תיקון שוקי 19.07.08
אשנב   מצגת הורים- תיקון שוקי 19.07.08אשנב   מצגת הורים- תיקון שוקי 19.07.08
אשנב מצגת הורים- תיקון שוקי 19.07.08benny
 
Library resources at your fingertips 2012 slide share
Library resources at your fingertips 2012 slide share Library resources at your fingertips 2012 slide share
Library resources at your fingertips 2012 slide share Naz Torabi
 
דרום העיר לאנשים-june23
דרום העיר לאנשים-june23דרום העיר לאנשים-june23
דרום העיר לאנשים-june23south.ta.plan
 
Animations
AnimationsAnimations
Animationsguru090
 
안드로이드스터디 11
안드로이드스터디 11안드로이드스터디 11
안드로이드스터디 11jangpd007
 
Chambwe bosc2010
Chambwe bosc2010Chambwe bosc2010
Chambwe bosc2010BOSC 2010
 
Westweaves Profile
Westweaves ProfileWestweaves Profile
Westweaves Profileanantdamani
 
Pasajeros imágenes (2010)
Pasajeros imágenes (2010)Pasajeros imágenes (2010)
Pasajeros imágenes (2010)Tandanor SACIyN
 
For nada
For nadaFor nada
For nadaOMNIE
 
Bcerac IL4K12 November 2014 slides
Bcerac IL4K12 November 2014 slidesBcerac IL4K12 November 2014 slides
Bcerac IL4K12 November 2014 slidesKevin Amboe
 
Educatieve spelen voor upload naar moodle
Educatieve spelen voor upload naar moodleEducatieve spelen voor upload naar moodle
Educatieve spelen voor upload naar moodleCVO-SSH
 

Andere mochten auch (20)

Moeller bosc2010 debian_taverna
Moeller bosc2010 debian_tavernaMoeller bosc2010 debian_taverna
Moeller bosc2010 debian_taverna
 
Moderaterna - Måndagens frukostseminarie i Almedalen -
Moderaterna - Måndagens frukostseminarie i Almedalen - Moderaterna - Måndagens frukostseminarie i Almedalen -
Moderaterna - Måndagens frukostseminarie i Almedalen -
 
안드로이드스터디 2
안드로이드스터디 2안드로이드스터디 2
안드로이드스터디 2
 
Skate
SkateSkate
Skate
 
Asv
AsvAsv
Asv
 
suiza
suizasuiza
suiza
 
אשנב מצגת הורים- תיקון שוקי 19.07.08
אשנב   מצגת הורים- תיקון שוקי 19.07.08אשנב   מצגת הורים- תיקון שוקי 19.07.08
אשנב מצגת הורים- תיקון שוקי 19.07.08
 
Library resources at your fingertips 2012 slide share
Library resources at your fingertips 2012 slide share Library resources at your fingertips 2012 slide share
Library resources at your fingertips 2012 slide share
 
דרום העיר לאנשים-june23
דרום העיר לאנשים-june23דרום העיר לאנשים-june23
דרום העיר לאנשים-june23
 
Animations
AnimationsAnimations
Animations
 
안드로이드스터디 11
안드로이드스터디 11안드로이드스터디 11
안드로이드스터디 11
 
Chambwe bosc2010
Chambwe bosc2010Chambwe bosc2010
Chambwe bosc2010
 
Westweaves Profile
Westweaves ProfileWestweaves Profile
Westweaves Profile
 
Pasajeros imágenes (2010)
Pasajeros imágenes (2010)Pasajeros imágenes (2010)
Pasajeros imágenes (2010)
 
For nada
For nadaFor nada
For nada
 
Bcerac IL4K12 November 2014 slides
Bcerac IL4K12 November 2014 slidesBcerac IL4K12 November 2014 slides
Bcerac IL4K12 November 2014 slides
 
Educatieve spelen voor upload naar moodle
Educatieve spelen voor upload naar moodleEducatieve spelen voor upload naar moodle
Educatieve spelen voor upload naar moodle
 
Introduction to LEAN (handout)
Introduction to LEAN (handout)Introduction to LEAN (handout)
Introduction to LEAN (handout)
 
Cau kien 71 105
Cau kien 71 105Cau kien 71 105
Cau kien 71 105
 
Summer grandkids
Summer grandkidsSummer grandkids
Summer grandkids
 

Ähnlich wie Digging Deeper into Drupal's Presentation Layer

Grok Drupal (7) Theming (presented at DrupalCon San Francisco)
Grok Drupal (7) Theming (presented at DrupalCon San Francisco)Grok Drupal (7) Theming (presented at DrupalCon San Francisco)
Grok Drupal (7) Theming (presented at DrupalCon San Francisco)Laura Scott
 
Modules Building Presentation
Modules Building PresentationModules Building Presentation
Modules Building Presentationhtyson
 
Default theme implementations: a guide for module developers that want sweet ...
Default theme implementations: a guide for module developers that want sweet ...Default theme implementations: a guide for module developers that want sweet ...
Default theme implementations: a guide for module developers that want sweet ...John Albin Wilkins
 
Introduction to Drupal (7) Theming
Introduction to Drupal (7) ThemingIntroduction to Drupal (7) Theming
Introduction to Drupal (7) ThemingRobert Carr
 
Atlanta Drupal User Group (ADUG)
Atlanta Drupal User Group (ADUG) Atlanta Drupal User Group (ADUG)
Atlanta Drupal User Group (ADUG) Mediacurrent
 
Views Style Plugins
Views Style PluginsViews Style Plugins
Views Style Pluginsmwrather
 
Drupal Camp Porto - Developing with Drupal: First Steps
Drupal Camp Porto - Developing with Drupal: First StepsDrupal Camp Porto - Developing with Drupal: First Steps
Drupal Camp Porto - Developing with Drupal: First StepsLuís Carneiro
 
WordPress Theme Design and Development Workshop - Day 2
WordPress Theme Design and Development Workshop - Day 2WordPress Theme Design and Development Workshop - Day 2
WordPress Theme Design and Development Workshop - Day 2Mizanur Rahaman Mizan
 
Jumpstart Your Development with ZopeSkel
Jumpstart Your Development with ZopeSkelJumpstart Your Development with ZopeSkel
Jumpstart Your Development with ZopeSkelCristopher Ewing
 
Theming Search Results - How to Make Your Search Results Rock
Theming Search Results - How to Make Your Search Results RockTheming Search Results - How to Make Your Search Results Rock
Theming Search Results - How to Make Your Search Results RockAubrey Sambor
 
Django Overview
Django OverviewDjango Overview
Django OverviewBrian Tol
 
Crash Course in Theme Surgery
Crash Course in Theme SurgeryCrash Course in Theme Surgery
Crash Course in Theme SurgeryRational Frank
 
Wordpress theme development
Wordpress theme developmentWordpress theme development
Wordpress theme developmentNaeem Junejo
 
Advanced guide to develop ajax applications using dojo
Advanced guide to develop ajax applications using dojoAdvanced guide to develop ajax applications using dojo
Advanced guide to develop ajax applications using dojoFu Cheng
 
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
 
Theming in WordPress - Where do I Start?
Theming in WordPress - Where do I Start?Theming in WordPress - Where do I Start?
Theming in WordPress - Where do I Start?Edmund Turbin
 
WordPress Themes 101 - PSUWeb13 Workshop
WordPress Themes 101 - PSUWeb13 WorkshopWordPress Themes 101 - PSUWeb13 Workshop
WordPress Themes 101 - PSUWeb13 WorkshopCurtiss Grymala
 

Ähnlich wie Digging Deeper into Drupal's Presentation Layer (20)

Grok Drupal (7) Theming (presented at DrupalCon San Francisco)
Grok Drupal (7) Theming (presented at DrupalCon San Francisco)Grok Drupal (7) Theming (presented at DrupalCon San Francisco)
Grok Drupal (7) Theming (presented at DrupalCon San Francisco)
 
Modules Building Presentation
Modules Building PresentationModules Building Presentation
Modules Building Presentation
 
Efficient theming in Drupal
Efficient theming in DrupalEfficient theming in Drupal
Efficient theming in Drupal
 
Default theme implementations: a guide for module developers that want sweet ...
Default theme implementations: a guide for module developers that want sweet ...Default theme implementations: a guide for module developers that want sweet ...
Default theme implementations: a guide for module developers that want sweet ...
 
Introduction to Drupal (7) Theming
Introduction to Drupal (7) ThemingIntroduction to Drupal (7) Theming
Introduction to Drupal (7) Theming
 
Atlanta Drupal User Group (ADUG)
Atlanta Drupal User Group (ADUG) Atlanta Drupal User Group (ADUG)
Atlanta Drupal User Group (ADUG)
 
Views Style Plugins
Views Style PluginsViews Style Plugins
Views Style Plugins
 
Drupal Camp Porto - Developing with Drupal: First Steps
Drupal Camp Porto - Developing with Drupal: First StepsDrupal Camp Porto - Developing with Drupal: First Steps
Drupal Camp Porto - Developing with Drupal: First Steps
 
WordPress Theme Design and Development Workshop - Day 2
WordPress Theme Design and Development Workshop - Day 2WordPress Theme Design and Development Workshop - Day 2
WordPress Theme Design and Development Workshop - Day 2
 
Jumpstart Your Development with ZopeSkel
Jumpstart Your Development with ZopeSkelJumpstart Your Development with ZopeSkel
Jumpstart Your Development with ZopeSkel
 
Theming Search Results - How to Make Your Search Results Rock
Theming Search Results - How to Make Your Search Results RockTheming Search Results - How to Make Your Search Results Rock
Theming Search Results - How to Make Your Search Results Rock
 
Django Overview
Django OverviewDjango Overview
Django Overview
 
Crash Course in Theme Surgery
Crash Course in Theme SurgeryCrash Course in Theme Surgery
Crash Course in Theme Surgery
 
Wordpress theme development
Wordpress theme developmentWordpress theme development
Wordpress theme development
 
Advanced guide to develop ajax applications using dojo
Advanced guide to develop ajax applications using dojoAdvanced guide to develop ajax applications using dojo
Advanced guide to develop ajax applications using dojo
 
Django at Scale
Django at ScaleDjango at Scale
Django at Scale
 
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
 
Theming in WordPress - Where do I Start?
Theming in WordPress - Where do I Start?Theming in WordPress - Where do I Start?
Theming in WordPress - Where do I Start?
 
Intro to HTML 5 / CSS 3
Intro to HTML 5 / CSS 3Intro to HTML 5 / CSS 3
Intro to HTML 5 / CSS 3
 
WordPress Themes 101 - PSUWeb13 Workshop
WordPress Themes 101 - PSUWeb13 WorkshopWordPress Themes 101 - PSUWeb13 Workshop
WordPress Themes 101 - PSUWeb13 Workshop
 

Digging Deeper into Drupal's Presentation Layer

  • 1. Advanced Theming Digging deeper into Drupal’s presentation layer http://knowclassic.com
  • 2. Who am I? • Thomas Lattimore, often know as @tlattimore • Front-End Developer for Classic Graphics • Drupal enthusiast! • See what I do: drupal.org/user/624754 http://knowclassic.com
  • 3. This Session • Assumes you have understanding of Drupal theming • The basic anatomy of a theme including .info, template.php, .tpl's, & how sub-theming works. • ... and you can write own CSS/HTML with some understanding of PHP • You want to do more than Drupal's default output • This can include markup, attributes, or data formatting
  • 5. Overrides! What Drupal theming is made of • CSS • .tpl.php • Function(s) - in template.php
  • 6.
  • 10. Which method do I use? Answer:
  • 11. Which method do I use? It depends on your process Answer: and need
  • 13. Use CSS • If the markup (elements, classes, ids, etc) are already in place.
  • 14. Use CSS • If the markup (elements, classes, ids, etc) are already in place.
  • 15. Use CSS • If the markup (elements, classes, ids, etc) are already in place.
  • 16. Use CSS • If the markup (elements, classes, ids, etc) are already in place.
  • 17. Use CSS • If the markup (elements, classes, ids, etc) are already in place.
  • 18. Use CSS • If the markup (elements, classes, ids, etc) are already in place.
  • 19. Use CSS • If the markup (elements, classes, ids, etc) are already in place. • For better or for worse, Drupal has LOTS of selectors Use them!
  • 20. Tpl Override • If the markup and or attribute you want to override is already in a .tpl file • Template suggestion doc page: http://drupal.org/node/1089656
  • 22. Function Overrides • You need to actually dig into the data (stuff inside the $vars) before it hits the .tpl file, these functions go in template.php
  • 23. Function Overrides • You need to actually dig into the data (stuff inside the $vars) before it hits the .tpl file, these functions go in template.php • This includes (but is not exclusive to):
  • 24. Function Overrides • You need to actually dig into the data (stuff inside the $vars) before it hits the .tpl file, these functions go in template.php • This includes (but is not exclusive to): • hook_*_alter()
  • 25. Function Overrides • You need to actually dig into the data (stuff inside the $vars) before it hits the .tpl file, these functions go in template.php • This includes (but is not exclusive to): • hook_*_alter() • template_preprocess()
  • 26. Function Overrides • You need to actually dig into the data (stuff inside the $vars) before it hits the .tpl file, these functions go in template.php • This includes (but is not exclusive to): • hook_*_alter() • template_preprocess() • theme_hook()
  • 28. Function Overrides This is where things really get fun! (and largely what we’ll cover today)
  • 29. Common alter hooks • hook_page_alter() • A HUGE array of all the regions on the page • hook_form_alter() • Alter all sorts of form goodies • hook_css_alter() • Move around the order in which css is printed
  • 31. template_preprocess() • Includes: template_preprocess(), template_preprocess_page(), template_preprocess_node(), and more... • template_preprocess() • Add and modify variables before they hit there corresponding .tpl • Add tpl suggestions via ‘theme_hook_suggestions’ array
  • 32. template_preprocess() • Includes: template_preprocess(), template_preprocess_page(), template_preprocess_node(), and more... • template_preprocess() • Add and modify variables before they hit there corresponding .tpl • Add tpl suggestions via ‘theme_hook_suggestions’ array Basically, generates the themable output
  • 33. Today we are.... • Sub-theming bartik (for simplicities sake) • Using devel + devel_themer

Hinweis der Redaktion

  1. \n
  2. \n
  3. \n
  4. \n
  5. \n
  6. \n
  7. \n
  8. \n
  9. \n
  10. \n
  11. \n
  12. \n
  13. \n
  14. \n
  15. \n
  16. \n
  17. \n
  18. \n
  19. \n
  20. \n
  21. \n
  22. \n
  23. \n
  24. \n
  25. \n
  26. \n
  27. \n
  28. \n