Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Theming tips and tricks


Published on

  • Be the first to comment

  • Be the first to like this

Theming tips and tricks

  1. 1. Theming Tips and Tricks DrupalCamp Wisconsin July 23 rd 2010
  2. 2. Ways in Which We Will Override Presentation Templates Theme Functions Preprocess Functions Module Hooks
  3. 3. Templates vs. Theme Functions <ul><li>Core, modules, and themes output xhtml through templates and functions
  4. 4. You can overwrite this! </li></ul>
  5. 5. Templates <ul><li>Files ending in *.tpl.php
  6. 6. Overwritten by placing file in theme folder
  7. 7. Default templates include page.tpl.php, node.tpl.php, block.tpl.php
  8. 8. Default list: </li></ul>
  9. 9. Theme Functions <ul><li>Five times faster than templates!
  10. 10. For themers, place in template.php </li></ul>
  11. 11. Preprocess Functions <ul><li>Add or overwrite variables to template files
  12. 12. Often used in template.php
  13. 13. themename_ preprocess_page can be used for page.tpl.php </li></ul>
  14. 14. Module Hooks <ul><li>You can also overwrite output using hooks in modules
  15. 15. “ Business logic” belongs in modules
  16. 16. I'm looking at you hook_form_alter and hook_nodeapi ! </li></ul>
  17. 17. Theming Documentation It is excellent:
  18. 18. Theme developer Find what you are looking for!
  19. 19. Add Dimension to Your Blocks = boring = awesome! Add background to block titles Add extra div to block.tpl.php (using zen and only on second sidebar go with block-sidebar_second.tpl.php) see: Add background image to extra div
  20. 20. Make Your Comments Look un-Drupal <ul><li>Find a cool looking comments ( )
  21. 21. Drop your base theme or core comment.tpl.php in your theme folder
  22. 22. Add some divs, move variables, and give it some css </li></ul>
  23. 23. Theme Functions <ul><li>Overwrite 'submitted by'
  24. 24. theme_node_submitted($node) </li></ul>
  25. 25. Theme Functions <ul>theme_links() overwrite output of primary menu </ul>
  26. 26. Theme Functions <ul>theme_imagecache() add description to images! </ul>
  27. 27. Preprocces! <ul><li>Update comment time
  28. 28. Make title different colors
  29. 29. Add a 'Add your photo' Button </li></ul>
  30. 30. Module Hooks <ul><li>Edit search form
  31. 31. Message to administrators
  32. 32. Adding your own theme functions and templates </li></ul>
  33. 33. Useful theming modules Nice menus Quick tabs Skinr