Functions and templates that present output to the user, and can be implemented by themes.
Drupal's presentation layer is a pluggable system known as the theme layer. Each theme can take control over most of Drupal's output, and has complete control over the CSS.
Inside Drupal, the theme layer is utilized by the use of the theme() function, which is passed the name of a component (the theme hook) and several arguments. For example, theme('table', $header, $rows); Additionally, the theme() function can take an array of theme hooks, which can be used to provide 'fallback' implementations to allow for more specific control of output. For example, the function: theme(array('table__foo', 'table'), $header, $rows) would look to see if 'table__foo' is registered anywhere; if it is not, it would 'fall back' to the generic 'table' implementation. This can be used to attach specific theme functions to named objects, allowing the themer more control over specific types of output.
As of Drupal 6, every theme hook is required to be registered by the module that owns it, so that Drupal can tell what to do with it and to make it simple for themes to identify and override the behavior for these calls.
The theme hooks are registered via hook_theme(), which returns an array of arrays with information about the hook. It describes the arguments the function or template will need, and provides defaults for the template in case they are not filled in. If the default implementation is a function, by convention it is named theme_HOOK().
Each module should provide a default implementation for theme_hooks that it registers. This implementation may be either a function or a template; if it is a function it must be specified via hook_theme(). By convention, default implementations of theme hooks are named theme_HOOK. Default template implementations are stored in the module directory.
Drupal's default template renderer is a simple PHP parsing engine that includes the template and stores the output. Drupal's theme engines can provide alternate template engines, such as XTemplate, Smarty and PHPTal. The most common template engine is PHPTemplate (included with Drupal and implemented in phptemplate.engine, which uses Drupal's default template renderer.
In order to create theme-specific implementations of these hooks, themes can implement their own version of theme hooks, either as functions or templates. These implementations will be used instead of the default implementation. If using a pure .theme without an engine, the .theme is required to implement its own version of hook_theme() to tell Drupal what it is implementing; themes utilizing an engine will have their well-named theming functions automatically registered for them. While this can vary based upon the theme engine, the standard set by phptemplate is that theme functions should be named either phptemplate_HOOK or THEMENAME_HOOK. For example, for Drupal's default theme (Garland) to implement the 'table' hook, the phptemplate.engine would find phptemplate_table() or garland_table(). The ENGINE_HOOK() syntax is preferred, as this can be used by sub-themes (which are themes that share code but use different stylesheets).
The theme system is described and defined in theme.inc.
|theme.inc||The theme system, which controls the output of Drupal.|
Functions & methods
|theme_blocks||Return a set of blocks available for the current user.|
|theme_box||Return a themed box.|
|theme_breadcrumb||Return a themed breadcrumb trail.|
|theme_closure||Execute hook_footer() which is run at the end of the page right before the close of the body tag.|
|theme_feed_icon||Return code that emits an feed icon.|
|theme_help||Return a themed help message.|
|theme_image||Return a themed image.|
|theme_indentation||Create a standard indentation div. Used for drag and drop tables.|
|theme_item_list||Return a themed list of items.|
|theme_links||Return a themed set of links.|
|theme_mark||Return a themed marker, useful for marking new or updated content.|
|theme_menu_item||Generate the HTML output for a menu item and submenu.|
|theme_menu_item_link||Generate the HTML output for a single menu link.|
|theme_menu_local_task||Generate the HTML output for a single local task link.|
|theme_menu_local_tasks||Returns the rendered local tasks. The default implementation renders them as tabs.|
|theme_menu_tree||Generate the HTML output for a menu tree|
|theme_more_help_link||Returns code that emits the 'more help'-link.|
|theme_more_link||Returns code that emits the 'more' link used on blocks.|
|theme_placeholder||Formats text for emphasized display in a placeholder inside a sentence. Used automatically by t().|
|theme_progress_bar||Return a themed progress bar.|
|theme_status_messages||Return a themed set of status and/or error messages. The messages are grouped by type.|
|theme_submenu||Return a themed submenu, typically displayed under the tabs.|
|theme_table||Return a themed table.|
|theme_tablesort_indicator||Return a themed sort icon.|
|theme_table_select_header_cell||Returns a header cell for tables that have a select all functionality.|
|theme_username||Format a username.|
|theme_xml_icon||Return code that emits an XML icon.|