Create a php config file from code

use <<< EOF and escape $variable

  1. $file_content = <<<EOF
  2. <?php
  3. \$conf['cache_backends'] = array('sites/thomas.lemaire.nameall/modules/contrib/apc/drupal_apc_cache.inc');
  4. \$conf['cache_class_cache'] = 'DrupalAPCCache';
  5. \$conf['cache_class_cache_bootstrap'] = 'DrupalAPCCache';
  6. EOF;

note: EOT is the new standard

  1. $data = <<<'EOT'
  2. .. with $var
  3. ..
  4. EOT;

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