This document discusses advanced theming techniques in Drupal. It outlines different methods for customizing Drupal's presentation layer, including using CSS, template overrides, and function overrides. Function overrides, which involve altering variables and data before it reaches template files, provide the most control and are covered in depth. Common hooks and functions for overrides are explained, such as hook_preprocess() and template_preprocess(), which allow modifying variables and adding template suggestions. The session aims to demonstrate how to dig deeper into Drupal's theming capabilities beyond basic CSS and templates.
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
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()
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