Custom	  forma+ers	  Jochen	  Verdeyen	  Nicolas	  Leroy	                            1.
Who are we?!     Nicolas Leroy      ¬    http://drupal.org/user/3527      ¬    @nicolasleroy      ¬    http://nicolasleroy...
Agenda!   Custom Formatters in Drupal 6 (CCK)    ¬    Using custom formatters module    ¬    Writing custom code          ...
4.
Custom Formatters in D6!     A custom formatter can be used to change the output of a      CCK field.!     Example: filefi...
CCK – Filefield Formatters           !     Go to the filefield module                 ¬    Filefield.module (hook_field_fo...
CCK – Filefield Formatters                             7.
How to add a custom formatter?!     Use the “custom formatters” module      ¬    http://drupal.org/project/custom_formatte...
Use the Custom Formatter module                                  9.
Your custom formatter                        10.
Write custom code                    11.
Write custom code!   hook_field_formatter_info (CCK)    ¬    Declares information about one or more field formatter types....
Example!     Real-life problem: Job section      ¬    Job postings on website      ¬    Applications online, saved as node...
Example: problem                   14.
Example: solution                    15.
16.
Custom Formatters in D7!     Custom Formatters module!     Write custom code      ¬    Coordinates Field module      ¬    ...
Coordinates Field module Form	               Formatted	                                      18.
Write custom code!   hook_theme!   hook_field_formatter_info    ¬    D6: CCK hook_field_formatter_info    ¬    CCK à D7 F...
hook_themegoogle-static-map.tpl.php	                               20.
hook_field_formatter_info                            Default values	                                                21.
hook_field_formatter_view                     coordinates	                     formatter settings	                     Goo...
hook_field_formatter_settings_form                                     23.
hook_field_formatter_settings_summary                                        24.
25.
26.
Drupal developer days 2011   custom formatters
Upcoming SlideShare
Loading in …5
×

Drupal developer days 2011 custom formatters

2,125 views
1,982 views

Published on

A presentation from a session at the drupal developer days 2011 in Brussels.
http://bxl2011.drupaldays.org/bxl2011.drupaldays.org/node/303.html

Published in: Technology
0 Comments
1 Like
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
2,125
On SlideShare
0
From Embeds
0
Number of Embeds
3
Actions
Shares
0
Downloads
0
Comments
0
Likes
1
Embeds 0
No embeds

No notes for slide

Drupal developer days 2011 custom formatters

  1. 1. Custom  forma+ers  Jochen  Verdeyen  Nicolas  Leroy   1.
  2. 2. Who are we?!   Nicolas Leroy ¬  http://drupal.org/user/3527 ¬  @nicolasleroy ¬  http://nicolasleroy.be!   Jochen Verdeyen ¬  http://drupal.org/user/310720 ¬  http://www.jover.be/ 2.
  3. 3. Agenda! Custom Formatters in Drupal 6 (CCK) ¬  Using custom formatters module ¬  Writing custom code ! Example: HR site! Custom Formatters in Drupal 7 (Core: Field API) ¬  Using custom formatters module ¬  Writing custom code ! Difference D6 – D7 ! Example: Coordinates – Google Static Maps 3.
  4. 4. 4.
  5. 5. Custom Formatters in D6!   A custom formatter can be used to change the output of a CCK field.!   Example: filefield 5.
  6. 6. CCK – Filefield Formatters !   Go to the filefield module ¬  Filefield.module (hook_field_formatter_info, hook_theme) ¬  Filefield_formatter.inc (theme hooks) 6.
  7. 7. CCK – Filefield Formatters 7.
  8. 8. How to add a custom formatter?!   Use the “custom formatters” module ¬  http://drupal.org/project/custom_formatters!   Write custom code 8.
  9. 9. Use the Custom Formatter module 9.
  10. 10. Your custom formatter 10.
  11. 11. Write custom code 11.
  12. 12. Write custom code! hook_field_formatter_info (CCK) ¬  Declares information about one or more field formatter types.! hook_theme ¬  Register a module (or theme’s) theme implementation.! theme_hook ¬  Generate a themed output. 12.
  13. 13. Example!   Real-life problem: Job section ¬  Job postings on website ¬  Applications online, saved as node ¬  View to show applications ¬  Some file names too long to display! http://my.www.devdays.be 13.
  14. 14. Example: problem 14.
  15. 15. Example: solution 15.
  16. 16. 16.
  17. 17. Custom Formatters in D7!   Custom Formatters module!   Write custom code ¬  Coordinates Field module ¬  Coordinates Formatter module 17.
  18. 18. Coordinates Field module Form Formatted 18.
  19. 19. Write custom code! hook_theme! hook_field_formatter_info ¬  D6: CCK hook_field_formatter_info ¬  CCK à D7 Field API! hook_field_formatter_info_alter! hook_field_formatter_view! hook_field_formatter_prepare_view! hook_field_formatter_settings_form! hook_field_formatter_settings_summary! http://api.drupal.org 19.
  20. 20. hook_themegoogle-static-map.tpl.php 20.
  21. 21. hook_field_formatter_info Default values 21.
  22. 22. hook_field_formatter_view coordinates formatter settings Google Static Map API implementation return variables 22.
  23. 23. hook_field_formatter_settings_form 23.
  24. 24. hook_field_formatter_settings_summary 24.
  25. 25. 25.
  26. 26. 26.

×