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.
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
11. Exportables
• Allows for exportable objects
• Exported objects run from code
• CTools handles the overrides
• Implemented in hook_schema()
12. 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
16. Modal Dialog
• Built on top of AJAX Responder
• Works especially well with forms
• Handles form validation and submission
workflows
17.
18. 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
19. 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)
20. Content
• re-usable content displays
• configurable options
• make use of contexts
• panels panes are “content” plugins
21. 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
23. 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
24. 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))
•
25. Drop-down links
• Dropdown menu links
• javascript based dropdowns
• panels "cogs"
• theme('ctools_dropdown', ...)