1. Navigate drupal to "Modules"
  2. Click "Add modual" near the top of the page.
  3. Goto, find your module page, scroll down to "Download," right click and save address of the tar file you want.
  4. Paste the address in to the module installer, and click install.
  5. Do NOT hit the "back arrow" on your browser.
  6. Go to the Modules page and activate it.



  • (for placing breakpoints in modules though, currently xdebug_break() does the trick.
  • A simple way that works for me is to use drupal_set_message('Some text') which ends up displaying in the message area on the page. So for printing a simple variable I might use something like drupal_set_message('Variable name: ' . $variable) or if the variable is an array or object something like drupal_set_message('Variable name: <pre>' . print_r($variable, TRUE) . '</pre>');
  • Good debugging page:

Links to Info:

Example Code:


1022 * Implements MODULE_preprocess_node().
1023 */
1024 function media_gallery_preprocess_node(&$variables) {
1025 // Do not show the title when a node is being displayed in a media gallery
1026 // block.
1027 if ($variables['view_mode'] == 'media_gallery_block') {
1028 $variables['title'] = '';
1029 }
1031 // Gallery teasers (for example, the ones that appear on the Galleries page)
1032 // require special theming of their content. We set that up here instead of as
1033 // part of hook_node_view_alter() or similar, because we want the node itself
1034 // to have #theme='node' as normal, and only want to add special theming for
1035 // the node content, but the content element isn't created until
1036 // template_preprocess_node().
1037 if ($variables['node']->type == 'media_gallery' && $variables['view_mode'] == 'teaser') {
1038 $variables['content']['#theme'] = 'media_gallery_teaser';
1039 $variables['content']['#node'] = $variables['node'];
1040 }
1041 }




Big picture: Drupal Core Default Theme  =>   Real Theme


  • HOOK:  A placehoder that must be replaced by, 'node', 'page', ect, or by a user theme name or user module name.
  • $vars:  An array of variables and arrays.  $vars[title] == $vars['title'] will turn into $title when it is handed to the template file or theme function (not sure how).
  • Template file: Mix of HTML & PHP and produces HTML output  shown on web page. HOOKname.tpl.php. The core template HOOKnames are: html, page, block, node, field, etc etc.
  • Theme function: Equivalent to a template file but for programmers instead of designers. Generates HTML output. Core theme functions are named theme_HOOK($vars), theme_breadcrumb(), etc. . API
  • theme($hook, $var): THE theme function (not one of the template-file equivalents). E.g. if $hook='node' it will call either the node template file or the node theme function and pass it $var from which it will generate HTML. API
  • Override: A template file of the same name in sites/all/themes/ will be run instead of the core template file. page--article.tpl.php will override core page.tpl.php for article nodes.

Three Scenarios:

  1. Build something (e.g. myblock) and theme it with a theme function in a module
  2. Build something and theme it with a template
  3. Tamper with the default or real theme

Scenario #1: Theme function. Define:   function theme_myblock($vars) { ... }

  • $vars = array( items => array('cat' => $cat; 'dog' => $dog,), 'title' => $title, type => $type, attributes => $attribs);
  • Never call function  theme_myblocks($vars).  Instead call:
  • theme('myblocks', $vars);
  • And drupal will call your function at the right time.


Info about head_title

Testing page


A very simple body.

Another page i


level 8

one to go

The Bottom Line