Default theme
implementations:
a guide for module developers
   who want sweet love from
     Morten and JohnAlbin
Who is this guy
and what the hell is he going
      to talk about?
JohnAlbin   (Wilkins)   Me and 19 other people wrote
  ...
Separation of Concerns
Flow of Themed Content
A simplified wiring guide to the Theme Layer
Theme Hooks
        username
pager                             links
                   node

comment                   ta...
BE LAZY!
 Pick an existing theme hook (if you can)

links                     file_link
image                     html_tag...
Laziness advntgs:
• Less work. (duh.)
 • Notemplate or theme function,
    no
        hook_theme(),

    no template_prepr...
Theme hook suggestions
(You, too, can be as awesome as Earl Miles.)



• theme(‘hook’, $vars);
• theme(‘hook__suggestion’,...
Roll Your Own
• hook_theme() describes theme hooks
 • wtf_ftw()
 • define default variables
• Picking a theme function or ...
Separation of layers (again)

  • Data should be passed in as parameters
  • Display preprocess function
    in via a
    ...
Things that will make
      me angry
• Never, EVERa pull data
  from inside theme function
• If you have toitcall aa theme...
Avoid accidental 3-ways




 It’s likely you won’t get what you expect.
Provide context

• Meta data is just important to a themer
  as the actual data.
Mark-up and CSS
• Do your best.
• Less is more.
• Contextual CSS classes.
• Seek help.
 • Mark-up Marines: #drupal-design
Share the love!
What
did
you
think?
                  Step 1)
   Locate this session on the DCSF site

h.p://sf2010.drupal.org/conference/...
Upcoming SlideShare
Loading in …5
×

Default theme implementations: a guide for module developers that want sweet love from Morten and JohnAlbin

5,489 views

Published on

Drupalcon San Francisco presentation. Best practices for Drupal module developers as they implement the theme layer.

Published in: Technology
2 Comments
7 Likes
Statistics
Notes
No Downloads
Views
Total views
5,489
On SlideShare
0
From Embeds
0
Number of Embeds
24
Actions
Shares
0
Downloads
124
Comments
2
Likes
7
Embeds 0
No embeds

No notes for slide

Default theme implementations: a guide for module developers that want sweet love from Morten and JohnAlbin

  1. 1. Default theme implementations: a guide for module developers who want sweet love from Morten and JohnAlbin
  2. 2. Who is this guy and what the hell is he going to talk about? JohnAlbin (Wilkins) Me and 19 other people wrote 50% of Drupal 7 • Brief overview of the theme layer • Theme hook suggestions • Best practices for BYO Implementations
  3. 3. Separation of Concerns
  4. 4. Flow of Themed Content
  5. 5. A simplified wiring guide to the Theme Layer
  6. 6. Theme Hooks username pager links node comment table page item_list theme(‘theme_hook_name’, $data)
  7. 7. BE LAZY! Pick an existing theme hook (if you can) links file_link image html_tag image_style more_link item_list pager username progress_bar table http://api.drupal.org/api/group/themeable/7
  8. 8. Laziness advntgs: • Less work. (duh.) • Notemplate or theme function, no hook_theme(), no template_preprocess_HOOK(), etc. • Just: theme(‘hook’, $vars); • Themersre-used. know how to style hooks that you already • Instant integration with other modules!
  9. 9. Theme hook suggestions (You, too, can be as awesome as Earl Miles.) • theme(‘hook’, $vars); • theme(‘hook__suggestion’, $vars); (D7 only) • theme($suggestions_array, $vars);
  10. 10. Roll Your Own • hook_theme() describes theme hooks • wtf_ftw() • define default variables • Picking a theme function or a template • functions are faster • templates are easier
  11. 11. Separation of layers (again) • Data should be passed in as parameters • Display preprocess function in via a options should be params or pulled • Meta data should be modifiable by preprocess functions
  12. 12. Things that will make me angry • Never, EVERa pull data from inside theme function • If you have toitcall aa theme function!!! value, do NOT put in function to get a • Don’t be like D6’s theme_local_menus()
  13. 13. Avoid accidental 3-ways It’s likely you won’t get what you expect.
  14. 14. Provide context • Meta data is just important to a themer as the actual data.
  15. 15. Mark-up and CSS • Do your best. • Less is more. • Contextual CSS classes. • Seek help. • Mark-up Marines: #drupal-design
  16. 16. Share the love!
  17. 17. What
did
you
think? Step 1) Locate this session on the DCSF site 
h.p://sf2010.drupal.org/conference/schedule Step 2) Click the “Take Survey” link

×