Big picture: Drupal Core Default Theme => Real Theme
Definitions:
-
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:
-
Build something (e.g. myblock) and theme it with a theme function in a module
-
Build something and theme it with a template
-
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 http://drupal.org/node/655742