Same name and namespace in other branches
  1. 4.7.x includes/theme.inc \theme()
  2. 5.x includes/theme.inc \theme()
  3. 6.x includes/theme.inc \theme()
  4. 7.x includes/theme.inc \theme()

Generate the themed representation of a Drupal object.

All requests for themed functions must go through this function. It examines the request and routes it to the appropriate theme function. If the current theme does not implement the requested function, then the current theme engine is checked. If neither the engine nor theme implement the requested function, then the base theme function is called.

For example, to retrieve the HTML that is output by theme_page($output), a module should call theme('page', $output).

Parameters

$function: The name of the theme function to call.

...: Additional arguments to pass along to the theme function.

Return value

An HTML string that generates the themed output.

218 calls to theme()
aggregator_admin_edit_category in modules/aggregator.module
Menu callback; displays the category edit form, or saves changes and redirects to the overview page.
aggregator_admin_edit_feed in modules/aggregator.module
Menu callback; displays the feed edit form.
aggregator_admin_overview in modules/aggregator.module
Menu callback; displays the aggregator administration page.
aggregator_block in modules/aggregator.module
Implementation of hook_block().
aggregator_edit in modules/aggregator.module

... See full list

3 string references to 'theme'
system_theme_data in modules/system.module
Collect data about all currently available themes
system_theme_listing in modules/system.module
Generate a list of all the available theme/style combinations.
system_user in modules/system.module
Implementation of hook_user().

File

includes/theme.inc, line 172
The theme system, which controls the output of Drupal.

Code

function theme() {
  global $theme, $theme_engine;
  if (!$theme) {

    // Initialize the enabled theme.
    $theme = init_theme();
  }
  $args = func_get_args();
  $function = array_shift($args);
  if ($theme != '' && function_exists($theme . '_' . $function)) {

    // call theme function
    return call_user_func_array($theme . '_' . $function, $args);
  }
  elseif ($theme != '' && isset($theme_engine) && function_exists($theme_engine . '_' . $function)) {

    // call engine function
    return call_user_func_array($theme_engine . '_' . $function, $args);
  }
  elseif (function_exists('theme_' . $function)) {

    // call Drupal function
    return call_user_func_array('theme_' . $function, $args);
  }
}