SlideShare ist ein Scribd-Unternehmen logo
1 von 27
Custom	
  forma+ers	
  
Jochen	
  Verdeyen	
  
Nicolas	
  Leroy	
  


                          1.
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.
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.
Custom Formatters in D6
!     A custom formatter can be used to change the output of a
      CCK field.
!     Example: filefield




                                                                 5.
CCK – Filefield Formatters

           !     Go to the filefield module
                 ¬    Filefield.module (hook_field_formatter_info,
                      hook_theme)
                 ¬    Filefield_formatter.inc (theme hooks)




                                                                     6.
CCK – Filefield Formatters




                             7.
How to add a custom formatter?
!     Use the “custom formatters” module
      ¬    http://drupal.org/project/custom_formatters




!     Write custom code


                                                         8.
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.
!   hook_theme
    ¬    Register a module (or theme’s) theme implementation.
!   theme_hook
    ¬    Generate a themed output.




                                                                         12.
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.
Example: problem




                   14.
Example: solution




                    15.
16.
Custom Formatters in D7
!     Custom Formatters module
!     Write custom code
      ¬    Coordinates Field module
      ¬    Coordinates Formatter module




                                          17.
Coordinates Field module

 Form	

               Formatted	





                                      18.
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.
hook_theme




google-static-map.tpl.php	





                               20.
hook_field_formatter_info




                            Default values	





                                                21.
hook_field_formatter_view


                     coordinates	


                     formatter settings	



                     Google Static Map API implementation	





                     return variables	





                                                               22.
hook_field_formatter_settings_form




                                     23.
hook_field_formatter_settings_summary




                                        24.
25.
26.
Drupal developer days 2011   custom formatters

Weitere ähnliche Inhalte

Ähnlich wie Drupal developer days 2011 custom formatters

Social Connections VI — IBM Connections Extensions and Themes Demystified
Social Connections VI — IBM Connections Extensions and Themes DemystifiedSocial Connections VI — IBM Connections Extensions and Themes Demystified
Social Connections VI — IBM Connections Extensions and Themes DemystifiedClaudio Procida
 
Pluggable patterns
Pluggable patternsPluggable patterns
Pluggable patternsCorey Oordt
 
Blisstering drupal module development ppt v1.2
Blisstering drupal module development ppt v1.2Blisstering drupal module development ppt v1.2
Blisstering drupal module development ppt v1.2Anil Sagar
 
Shortify for Android
Shortify for AndroidShortify for Android
Shortify for AndroidDhruv Patel
 
Configuring in the Browser, Really!
Configuring in the Browser, Really!Configuring in the Browser, Really!
Configuring in the Browser, Really!Tim Geisler
 
Build a notepad application with PHP, MongoDB, and IBM Bluemix - by Vikram Va...
Build a notepad application with PHP, MongoDB, and IBM Bluemix - by Vikram Va...Build a notepad application with PHP, MongoDB, and IBM Bluemix - by Vikram Va...
Build a notepad application with PHP, MongoDB, and IBM Bluemix - by Vikram Va...Carlos Tomas
 
Organinzing Your PHP Projects (2010 Memphis PHP)
Organinzing Your PHP Projects (2010 Memphis PHP)Organinzing Your PHP Projects (2010 Memphis PHP)
Organinzing Your PHP Projects (2010 Memphis PHP)Paul Jones
 
Organizing Your PHP Projects (2010 ConFoo)
Organizing Your PHP Projects (2010 ConFoo)Organizing Your PHP Projects (2010 ConFoo)
Organizing Your PHP Projects (2010 ConFoo)Paul Jones
 
Drupal Recipe
Drupal RecipeDrupal Recipe
Drupal Recipehernanibf
 
Docman - The swiss army knife for Drupal multisite docroot management and dep...
Docman - The swiss army knife for Drupal multisite docroot management and dep...Docman - The swiss army knife for Drupal multisite docroot management and dep...
Docman - The swiss army knife for Drupal multisite docroot management and dep...Aleksey Tkachenko
 
Drupal training-by-ruchiwebsolutions
Drupal training-by-ruchiwebsolutionsDrupal training-by-ruchiwebsolutions
Drupal training-by-ruchiwebsolutionsphp2ranjan
 
"Paragraphs are more powerful than you can expect" from Vasily Jaremchuk for ...
"Paragraphs are more powerful than you can expect" from Vasily Jaremchuk for ..."Paragraphs are more powerful than you can expect" from Vasily Jaremchuk for ...
"Paragraphs are more powerful than you can expect" from Vasily Jaremchuk for ...DrupalCamp Kyiv
 
Tutorial Expert How-To - Custom properties
Tutorial Expert How-To - Custom propertiesTutorial Expert How-To - Custom properties
Tutorial Expert How-To - Custom propertiesPascalDesmarets1
 
How to become a Rational Developer for IBM i Power User
How to become a Rational Developer for IBM i Power UserHow to become a Rational Developer for IBM i Power User
How to become a Rational Developer for IBM i Power UserStrongback Consulting
 
Easy Drupal Project Deployment With Features Module & Drush
Easy Drupal Project Deployment With Features Module & DrushEasy Drupal Project Deployment With Features Module & Drush
Easy Drupal Project Deployment With Features Module & DrushQArea
 
Taking your module from Drupal 6 to Drupal 7
Taking your module from Drupal 6 to Drupal 7Taking your module from Drupal 6 to Drupal 7
Taking your module from Drupal 6 to Drupal 7Phase2
 
Should I Be Writing My Own Web Experience Factory Builder? TECH-D13 from IBM ...
Should I Be Writing My Own Web Experience Factory Builder? TECH-D13 from IBM ...Should I Be Writing My Own Web Experience Factory Builder? TECH-D13 from IBM ...
Should I Be Writing My Own Web Experience Factory Builder? TECH-D13 from IBM ...Davalen LLC
 
Building and Maintaining a Distribution in Drupal 7 with Features
Building and Maintaining a  Distribution in Drupal 7 with FeaturesBuilding and Maintaining a  Distribution in Drupal 7 with Features
Building and Maintaining a Distribution in Drupal 7 with FeaturesNuvole
 
WordCamp ABQ 2013: Making the leap from Designer to Designer/Developer
WordCamp ABQ 2013: Making the leap from Designer to Designer/DeveloperWordCamp ABQ 2013: Making the leap from Designer to Designer/Developer
WordCamp ABQ 2013: Making the leap from Designer to Designer/Developermy easel
 

Ähnlich wie Drupal developer days 2011 custom formatters (20)

Social Connections VI — IBM Connections Extensions and Themes Demystified
Social Connections VI — IBM Connections Extensions and Themes DemystifiedSocial Connections VI — IBM Connections Extensions and Themes Demystified
Social Connections VI — IBM Connections Extensions and Themes Demystified
 
Pluggable patterns
Pluggable patternsPluggable patterns
Pluggable patterns
 
Blisstering drupal module development ppt v1.2
Blisstering drupal module development ppt v1.2Blisstering drupal module development ppt v1.2
Blisstering drupal module development ppt v1.2
 
Shortify for Android
Shortify for AndroidShortify for Android
Shortify for Android
 
Configuring in the Browser, Really!
Configuring in the Browser, Really!Configuring in the Browser, Really!
Configuring in the Browser, Really!
 
Build a notepad application with PHP, MongoDB, and IBM Bluemix - by Vikram Va...
Build a notepad application with PHP, MongoDB, and IBM Bluemix - by Vikram Va...Build a notepad application with PHP, MongoDB, and IBM Bluemix - by Vikram Va...
Build a notepad application with PHP, MongoDB, and IBM Bluemix - by Vikram Va...
 
Organinzing Your PHP Projects (2010 Memphis PHP)
Organinzing Your PHP Projects (2010 Memphis PHP)Organinzing Your PHP Projects (2010 Memphis PHP)
Organinzing Your PHP Projects (2010 Memphis PHP)
 
Organizing Your PHP Projects (2010 ConFoo)
Organizing Your PHP Projects (2010 ConFoo)Organizing Your PHP Projects (2010 ConFoo)
Organizing Your PHP Projects (2010 ConFoo)
 
Drupal Recipe
Drupal RecipeDrupal Recipe
Drupal Recipe
 
Docman - The swiss army knife for Drupal multisite docroot management and dep...
Docman - The swiss army knife for Drupal multisite docroot management and dep...Docman - The swiss army knife for Drupal multisite docroot management and dep...
Docman - The swiss army knife for Drupal multisite docroot management and dep...
 
Drupal training-by-ruchiwebsolutions
Drupal training-by-ruchiwebsolutionsDrupal training-by-ruchiwebsolutions
Drupal training-by-ruchiwebsolutions
 
"Paragraphs are more powerful than you can expect" from Vasily Jaremchuk for ...
"Paragraphs are more powerful than you can expect" from Vasily Jaremchuk for ..."Paragraphs are more powerful than you can expect" from Vasily Jaremchuk for ...
"Paragraphs are more powerful than you can expect" from Vasily Jaremchuk for ...
 
Tutorial Expert How-To - Custom properties
Tutorial Expert How-To - Custom propertiesTutorial Expert How-To - Custom properties
Tutorial Expert How-To - Custom properties
 
How to become a Rational Developer for IBM i Power User
How to become a Rational Developer for IBM i Power UserHow to become a Rational Developer for IBM i Power User
How to become a Rational Developer for IBM i Power User
 
Intro to PDK
Intro to PDKIntro to PDK
Intro to PDK
 
Easy Drupal Project Deployment With Features Module & Drush
Easy Drupal Project Deployment With Features Module & DrushEasy Drupal Project Deployment With Features Module & Drush
Easy Drupal Project Deployment With Features Module & Drush
 
Taking your module from Drupal 6 to Drupal 7
Taking your module from Drupal 6 to Drupal 7Taking your module from Drupal 6 to Drupal 7
Taking your module from Drupal 6 to Drupal 7
 
Should I Be Writing My Own Web Experience Factory Builder? TECH-D13 from IBM ...
Should I Be Writing My Own Web Experience Factory Builder? TECH-D13 from IBM ...Should I Be Writing My Own Web Experience Factory Builder? TECH-D13 from IBM ...
Should I Be Writing My Own Web Experience Factory Builder? TECH-D13 from IBM ...
 
Building and Maintaining a Distribution in Drupal 7 with Features
Building and Maintaining a  Distribution in Drupal 7 with FeaturesBuilding and Maintaining a  Distribution in Drupal 7 with Features
Building and Maintaining a Distribution in Drupal 7 with Features
 
WordCamp ABQ 2013: Making the leap from Designer to Designer/Developer
WordCamp ABQ 2013: Making the leap from Designer to Designer/DeveloperWordCamp ABQ 2013: Making the leap from Designer to Designer/Developer
WordCamp ABQ 2013: Making the leap from Designer to Designer/Developer
 

Kürzlich hochgeladen

What is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfWhat is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfMounikaPolabathina
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxhariprasad279825
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Mark Simos
 
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024BookNet Canada
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfAlex Barbosa Coqueiro
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024Stephanie Beckett
 
Training state-of-the-art general text embedding
Training state-of-the-art general text embeddingTraining state-of-the-art general text embedding
Training state-of-the-art general text embeddingZilliz
 
What is Artificial Intelligence?????????
What is Artificial Intelligence?????????What is Artificial Intelligence?????????
What is Artificial Intelligence?????????blackmambaettijean
 
DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningDSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningLars Bell
 
A Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersA Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersNicole Novielli
 
Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...Rick Flair
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
Generative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersGenerative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersRaghuram Pandurangan
 
The State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxThe State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxLoriGlavin3
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 3652toLead Limited
 
Sample pptx for embedding into website for demo
Sample pptx for embedding into website for demoSample pptx for embedding into website for demo
Sample pptx for embedding into website for demoHarshalMandlekar2
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsSergiu Bodiu
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenHervé Boutemy
 
Time Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directionsTime Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directionsNathaniel Shimoni
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc
 

Kürzlich hochgeladen (20)

What is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfWhat is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdf
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptx
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
 
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdf
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024
 
Training state-of-the-art general text embedding
Training state-of-the-art general text embeddingTraining state-of-the-art general text embedding
Training state-of-the-art general text embedding
 
What is Artificial Intelligence?????????
What is Artificial Intelligence?????????What is Artificial Intelligence?????????
What is Artificial Intelligence?????????
 
DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningDSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine Tuning
 
A Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersA Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software Developers
 
Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
Generative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersGenerative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information Developers
 
The State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxThe State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptx
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365
 
Sample pptx for embedding into website for demo
Sample pptx for embedding into website for demoSample pptx for embedding into website for demo
Sample pptx for embedding into website for demo
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platforms
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache Maven
 
Time Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directionsTime Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directions
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
 

Drupal developer days 2011 custom formatters

  • 1. Custom  forma+ers   Jochen  Verdeyen   Nicolas  Leroy   1.
  • 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. 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.
  • 5. Custom Formatters in D6 !   A custom formatter can be used to change the output of a CCK field. !   Example: filefield 5.
  • 6. CCK – Filefield Formatters !   Go to the filefield module ¬  Filefield.module (hook_field_formatter_info, hook_theme) ¬  Filefield_formatter.inc (theme hooks) 6.
  • 7. CCK – Filefield Formatters 7.
  • 8. How to add a custom formatter? !   Use the “custom formatters” module ¬  http://drupal.org/project/custom_formatters !   Write custom code 8.
  • 9. Use the Custom Formatter module 9.
  • 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. 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.
  • 16. 16.
  • 17. Custom Formatters in D7 !   Custom Formatters module !   Write custom code ¬  Coordinates Field module ¬  Coordinates Formatter module 17.
  • 18. Coordinates Field module Form Formatted 18.
  • 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.
  • 21. hook_field_formatter_info Default values 21.
  • 22. hook_field_formatter_view coordinates formatter settings Google Static Map API implementation return variables 22.
  • 25. 25.
  • 26. 26.