Today was day 1 of DrupalCon D.C. I learn a lot and met a lot of interesting people. One of the people I met, Marjorie, asked me to post my notes from the Advanced Theming Session. Well, I did her one better and posted all my notes in Google Docs. BUT, since Google docs won't let me share my files with everyone (that I know of), I'll just have the post the notes she asked for here:
Advanced Theming Techniques
DrupalCon Day 1 – Session 5
March 4, 2009
.info files
Perfect place to
Add stylesheets
Add regions
Provide default settings
Include javascripts
Function overrides
Useful for work where more logic is required (mitigated by preprocess)
Better performance (function 5 times more efficient (docs)).
Theming at module level
Needed for theming new functionality.
Overriding
Everything in a theme can be overridden.
Two types of things you can override:
1.Template Files
1.Find the original template in
2.Copy it to your theme
3.Consider using a variant
Preprocess functions are better than template files
Separate logic (PHP) from appearance (HTML)
Less code, less bugs
Overriding theme functions
find the original theme function
Copy and paste into template.php
Rename from theme_HOOK() to name_HOOK
There is no preprocess for theme hooks, but you can modify the function arguments, then call the original theme function.
Warning: a module may have already overridden the original theme_HOOK() functionality.
Find out from the theme registry or theme_exists command.
Subtheming
Makes theming easier
Why a Subtheme?
Exaggerate the defaults
Get closer to the final goal before writing any code
Inherit, inherit, inherit, then override
In Drupal 6, subthemes go in sites/default/themes NOT sites/default/themes/zen/
Use Zen for Subtheming
Is there a good reason not to?
Framework is already set up
Theme Registry
Most theme work never notices the registry except to clear it. Remember to clear your cache!
The rest keeps us up at night
Theming Forms
Forms are a special case
If no custom theming is provided it just uses default theme
If you are theming a specific form, you need to define it in the theme registry
Two ways to do it:
Modify individual form elements
Work around the entire form
http://trellon.com/content/blog/theming-user-register-form-d6 for instructions and example of theming forms.
Marjorie is working on a book about Views for Drupal 5 with PACKT publishing, called Drupal 5 Views Recipes.
Google Docs annoys me...
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment