4.6.x theme.inc list_themes($refresh = FALSE)
4.7.x theme.inc list_themes($refresh = FALSE)
5.x theme.inc list_themes($refresh = FALSE)
6.x theme.inc list_themes($refresh = FALSE)
7.x theme.inc list_themes($refresh = FALSE)

Provides a list of currently available themes.

If the database is active then it will be retrieved from the database. Otherwise it will retrieve a new list.


$refresh: Whether to reload the list of themes from the database.

Return value

An array of the currently available themes.

7 calls to list_themes()
color_form_alter in modules/color/color.module
Implementation of hook_form_alter().
init_theme in includes/theme.inc
Initialize the theme system by loading the theme.
system_themes_form_submit in modules/system/system.admin.inc
Process system_themes_form form submissions.
system_theme_select_form in modules/system/system.module
Returns a fieldset containing the theme select form.
theme_get_setting in includes/theme.inc
Retrieve a setting for the current theme. This function is designed for use from within themes & engines to determine theme settings made in the admin interface.

... See full list


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


function list_themes($refresh = FALSE) {
  static $list = array();
  if ($refresh) {
    $list = array();
  if (empty($list)) {
    $list = array();
    $themes = array();

    // Extract from the database only when it is available.
    // Also check that the site is not in the middle of an install or update.
    if (db_is_active() && !defined('MAINTENANCE_MODE')) {
      $result = db_query("SELECT * FROM {system} WHERE type = '%s'", 'theme');
      while ($theme = db_fetch_object($result)) {
        if (file_exists($theme->filename)) {
          $theme->info = unserialize($theme->info);
          $themes[] = $theme;
    else {

      // Scan the installation when the database should not be read.
      $themes = _system_theme_data();
    foreach ($themes as $theme) {
      foreach ($theme->info['stylesheets'] as $media => $stylesheets) {
        foreach ($stylesheets as $stylesheet => $path) {
          $theme->stylesheets[$media][$stylesheet] = $path;
      foreach ($theme->info['scripts'] as $script => $path) {
        if (file_exists($path)) {
          $theme->scripts[$script] = $path;
      if (isset($theme->info['engine'])) {
        $theme->engine = $theme->info['engine'];
      if (isset($theme->info['base theme'])) {
        $theme->base_theme = $theme->info['base theme'];

      // Status is normally retrieved from the database. Add zero values when
      // read from the installation directory to prevent notices.
      if (!isset($theme->status)) {
        $theme->status = 0;
      $list[$theme->name] = $theme;
  return $list;