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.

Pure Sign Breakfast Presentations - Drupal FieldAPI

2,347 views

Published on

Introduction to Drupal FieldAPI.

Topics:
The different abstractions behind the FieldAPI.
The Drupal hooks needed to define your own custom Field.
The advantages of creating fields using the Drupal FieldAPI.

Published in: Technology
  • Be the first to comment

Pure Sign Breakfast Presentations - Drupal FieldAPI

  1. 1. toon@puresign.be Drupal FieldAPI @toonketels Pure Sign Breakfast Presentation 16/02/2012
  2. 2. Overview ‣ Entities ‣ Fields ‣ Anatomy of a field ‣ Creating a new fieldtype ‣ Why using the Field API ‣ Resources
  3. 3. Entities
  4. 4. Entities are the things, the data, the information, the “stuff”, that we want do deal with in our Drupal application. http://www.istos.it/comment/2882 Entities
  5. 5. Entities ‣ An abstraction for content ‣ Entities & bundles ‣ Created because not everything is a node ‣ What makes node powerful is their fieldability
  6. 6. Fields
  7. 7. The smallest data items we add to entities. Fields
  8. 8. Field type FieldField instance Layers of abstraction
  9. 9. Fields types ‣ Contains business logic of field ‣ Is conserned with: - What happens with data loaded from storage layer? - What should happen with data inputted by user to storage layer? ‣ Examples: - List - Text - Price - Link
  10. 10. Field types
  11. 11. Fields ‣ Data structure holding some settings ‣ A name and a type ‣ Link: field_website ‣ Some cannot be reverted, influence on db ‣ Settings apply everywhere field is used
  12. 12. Field
  13. 13. Field
  14. 14. Field
  15. 15. Field instance ‣ A field attached to a bundle ‣ Adds bundle specific settings ‣ bundle_fieldname
  16. 16. Field
  17. 17. Field
  18. 18. Anatomy of a Field
  19. 19. Field DisplayInput widget formatter Anatomy of a field
  20. 20. Creating a new fieldtype
  21. 21. 3 parts ‣ Defining a field ‣ Defining an input widget ‣ Defining a formatter
  22. 22. Field ‣ hook_field_info() ‣ hook_field_schema() ‣ hook_field_validate() ‣ hook_field_is_empty()
  23. 23. Widget ‣ hook_field_widget_info() ‣ hook_field_widget_form()
  24. 24. Formatter ‣ hook_field_formatter_info() ‣ hook_field_formatter_view()
  25. 25. Formatter
  26. 26. Code example
  27. 27. Why using the Field API
  28. 28. Why? ‣ It’s the way it goes...
  29. 29. Reusability ‣ Module: enable on any site ‣ We define a type ‣ Can be attached to any entity bundle ‣ User can customize it ‣ Create an instance
  30. 30. Pluggable ‣ Decouplingarchitecture ‣ Field data ‣ Input widget ‣ Display ‣ Other devs can ‣ Create input widgets ‣ Create formatters ‣ Alter (alter hooks)
  31. 31. Storage ‣ We don’t write sqlagnostic ‣ Data retrieval done for us ‣ Only implement schema ‣ Storage engine independent
  32. 32. Settings forfree ‣ Settings for free ‣ Required ‣ Help text ‣ Defaults ‣ Single - multiple - max
  33. 33. Settings for free
  34. 34. Single multiple, max number
  35. 35. Consistent UI build for us
  36. 36. UI ‣ Configure field ‣ Input widget ‣ Selection of formatter
  37. 37. Views integration
  38. 38. Viewsintegration ‣ Display field ‣ Multiple field settings ‣ Filter criteria ‣ compound_one ‣ compound_two ‣ delta ‣ Sort criteria ‣ compound_one ‣ compound_two ‣ delta
  39. 39. Features exportability
  40. 40. Display & DS ‣ Works with DS ‣ (better: DS works with fields)
  41. 41. Resources
  42. 42. Resources ‣ http://drupal.org/node/707832 ‣ http://api.drupal.org/api/drupal/ modules!field!field.module/group/ field/7 ‣ http://api.drupal.org/api/examples/ field_example %21field_example.module/7
  43. 43. toon@puresign.be @toonketels Questions?

×