Download - The Chaos Tools Suite
The Chaos Tools Suite
DrupalCon Paris, Sep 2009
WTF?
• Considered a sub-core by many.• Not as well-tested as core, but more agile.• I don’t have to argue over shed colors.• Collection of important API tools developed
based upon the needs of Views and Panels.• Starting to get a small cadre of devs who are
helping patch and expand the tools.• Two pieces went into core.
• Form wizards• AJAX• Modals• Exportables• Collapsible DIV• CSS caching and sanitization• Plugins
Form Wizards
• Start off with an array to describe the form• Each step within the form is a completely
independent form.• Uses server side caching to keep data between
steps.• Handles Back, Next, Finish and Cancel buttons
for you.• http://www.nicklewis.org/using-chaos-tools-
form-wizard-build-multistep-forms-drupal-6
Individual steps
• Each step is a normal FAPI form…almost.• The submit handler on each step should build
up data on the $form_state.• No permanent storage should happen here.• Order of steps can be changed during submit
handler by changing $form_state[‘clicked_button’][‘#next’]
AJAX Framework
• Links and forms can be AJAXified by adding classes.
• AJAX callbacks use a macro language to tell the server how to handle the returned data.
• Macro language is extensible so that you can add commands if you need to do something it does not already do.
WTF?• <a href=“/my/ajax/thing” class=“ctools-use-
ajax”>Click to do something ajaxy</a>
ctools_include('ajax'); $commands = array(); $commands[] = ctools_ajax_command_replace('#page-manager-list-pages', $table); if (!empty($replace_form)) { $commands[] = ctools_ajax_command_replace('#page-manager-list-pages-form', $form); } ctools_ajax_render($commands);
CTools Modal
• Builds on the AJAX framework.• Uses ctools-use-modal class to trigger modal
loading.• AJAX framework command to dismiss the
modal: ctools_ajax_modal_dismiss()• Automatically supported by the wizard.inc tool
by adding ‘modal’ => TRUE and ‘ajax’ => TRUE to the form state.
Collapsible DIV
CSS Caching
• Filter CSS from user input to remove dangerous items
• Store generated CSS in temporary files in the files directory. Similar to CSS aggregation.