Diese Präsentation wurde erfolgreich gemeldet.
Wir verwenden Ihre LinkedIn Profilangaben und Informationen zu Ihren Aktivitäten, um Anzeigen zu personalisieren und Ihnen relevantere Inhalte anzuzeigen. Sie können Ihre Anzeigeneinstellungen jederzeit ändern.
Embracing chaos
Leveraging the Chaos tool suite for
      module development
@zroger
drupal.org/user/67977
What is CTools?
“This suite is primarily a set of APIs and tools
to improve the developer experience. It also
contains a module called the...
Credit: http://www.flickr.com/photos/ontario_wanderer
The Tools
•   Plugins            •   Modal Dialog

•   Exportables        •   Dependent

•   AJAX Responder     •   Conten...
Credit: http://www.flickr.com/photos/jakematesdesign
Plugins
• Variation of the hook system
• Extensions of modules
• Several implementation methods
• Implementation by other ...
Credit: http://www.flickr.com/photos/thomashawk
Exportables
• Allows for exportable objects
• Exported objects run from code
• CTools handles the overrides
• Implemented ...
Form Tools
• replacements for Drupal's form functions
• ctools_build_form instead of
  drupal_get_form
              =



...
AJAX Responder




            Credit: http://www.flickr.com/photos/jimmyroq
AJAX Responder

• Command passing framework
• Common language (JSON)
• Command execution happens in javascript
• Command i...
Click Handler


                 AJAX Callback


AJAX Command
Modal Dialog
• Built on top of AJAX Responder
• Works especially well with forms
• Handles form validation and submission
...
Object Cache
• non-volatile cache
• mainly used for editing/creating complex
  objects
• allows for "unsaved" states
• the...
Contexts
• Packages objects into re-usable contexts
• Most often used with url args, similar to
  menu loader wildcards
• ...
Content
• re-usable content displays
• configurable options
• make use of contexts
• panels panes are “content” plugins
Form Wizard
• Form wizard
• multi-step forms, different from core
  multistep
• separate forms, vs a single form (the core...
CSS Tools
• disassemble CSS
• filter by properties/values
• reassemble CSS
• compress CSS
Dependent Fields
• Provides a simple mechanism for
  "dependent" form fields
• Form fields can be dependent on other
  fields...
Dependent Fields
• On any form item, add
• '#process' =>
    array('ctools_dependent_process')
• '#dependency' => array('i...
Drop-down links
• Dropdown menu links
• javascript based dropdowns
• panels "cogs"
• theme('ctools_dropdown', ...)
Leveraging the Chaos tool suite  for module development
Leveraging the Chaos tool suite  for module development
Nächste SlideShare
Wird geladen in …5
×

Leveraging the Chaos tool suite for module development

5.273 Aufrufe

Veröffentlicht am

CTools, aka the Chaos tool suite is one of the most popular and arguably least understood modules in the contributions repository. While most users will enable it only because of a dependency (i.e. panels), there are some wonderful gems in this tool kit that simplify module development.

Veröffentlicht in: Technologie
  • Als Erste(r) kommentieren

Leveraging the Chaos tool suite for module development

  1. 1. Embracing chaos Leveraging the Chaos tool suite for module development
  2. 2. @zroger drupal.org/user/67977
  3. 3. What is CTools?
  4. 4. “This suite is primarily a set of APIs and tools to improve the developer experience. It also contains a module called the Page Manager whose is to manage pages. In particular it manages panel pages, but as it grows it will be able to manage far more than just Panels.” - http://drupal.org/project/ctools
  5. 5. Credit: http://www.flickr.com/photos/ontario_wanderer
  6. 6. The Tools • Plugins • Modal Dialog • Exportables • Dependent • AJAX Responder • Content • Form Tools • Form wizard • Object caching • CSS Tools • Contexts • Others*
  7. 7. Credit: http://www.flickr.com/photos/jakematesdesign
  8. 8. Plugins • Variation of the hook system • Extensions of modules • Several implementation methods • Implementation by other modules • And themes too!
  9. 9. Credit: http://www.flickr.com/photos/thomashawk
  10. 10. Exportables • Allows for exportable objects • Exported objects run from code • CTools handles the overrides • Implemented in hook_schema()
  11. 11. Form Tools • replacements for Drupal's form functions • ctools_build_form instead of drupal_get_form = • uses form_state exclusively, no function args • basis of modal dialog and form wizard
  12. 12. AJAX Responder Credit: http://www.flickr.com/photos/jimmyroq
  13. 13. AJAX Responder • Command passing framework • Common language (JSON) • Command execution happens in javascript • Command invocation happens in PHP
  14. 14. Click Handler AJAX Callback AJAX Command
  15. 15. Modal Dialog • Built on top of AJAX Responder • Works especially well with forms • Handles form validation and submission workflows
  16. 16. Object Cache • non-volatile cache • mainly used for editing/creating complex objects • allows for "unsaved" states • the code responsible for the object is responsible for clearing the cache
  17. 17. Contexts • Packages objects into re-usable contexts • Most often used with url args, similar to menu loader wildcards • Contexts can be fetched from any condition (url,  • Contexts can be added manually (page manager)
  18. 18. Content • re-usable content displays • configurable options • make use of contexts • panels panes are “content” plugins
  19. 19. Form Wizard • Form wizard • multi-step forms, different from core multistep • separate forms, vs a single form (the core forms api) • very easy to add new forms (steps), re- order steps
  20. 20. CSS Tools • disassemble CSS • filter by properties/values • reassemble CSS • compress CSS
  21. 21. Dependent Fields • Provides a simple mechanism for "dependent" form fields • Form fields can be dependent on other fields • Usually dependent on the value of a checkbox, radio button or select
  22. 22. Dependent Fields • On any form item, add • '#process' => array('ctools_dependent_process') • '#dependency' => array('id-of-form- without-the-#' => array(list, of, values, that, make, this, gadget, visible)) •
  23. 23. Drop-down links • Dropdown menu links • javascript based dropdowns • panels "cogs" • theme('ctools_dropdown', ...)

×