Simple modal output with Ctools

Modal window provided by Ctools was designed to output forms but it can serve simple html as well.

  1. // in php
  2. ctools_include('modal');
  3. ctools_include('ajax');
  4. return ctools_modal_render("window title here", "content here");
  5.  
  6. // in javascript
  7. Drupal.CTools.Modal.show();
  8. $('#modal-title').html('title here');
  9. $('#modal-content').html('content here');

Form field conditionnal display

In this snippet the text field mycustom is only displayed if the value of the select field myoptions is custom

Theme and render

display some content using drupal_render() and theme (this is the official way to use theme function)

Simple block definition

Define and set content into a block. See hook_block_configure and hook_block_save if you want people be able to choose options.

Form declaration (from menu to submit)

Output a simple form, with validation and submit handlers

Jquery file structure declaration

Declare custom jquery code (attached to a theme or module) so that $ selector is available