theme_hook process: calling a theme function not working(example from DGD7) I'm just working through an example module in DGD7. The module reports statistics about the themes. It displays this information in the help region on the appearance admin page. 

I can't get it to display and I'm wondering if I understand the theming process correctly.

My understanding is this:


I call my function. (with a function)
My function returns data.
I tell drupal about my theme function with hook_theme
My theme function then turns my data into HTML.


Here's the module:

It uses a switch to call the function based on the path:

function xray_help($path, $arg) { 
 switch ($path) {
  case 'admin/appearance':
   return xray_appearance_summary();
 }
}


Then this function calls data from a stats function which returns a compact. (the stats function works - tested with dpm())

function xray_appearance_summary() {
  $data = array();
  $data['themes'] = xray_stats_enabled_themes();
  return $data;
}


They give a theme function (I'll put it last because it's quite long) but don't show how to call it with hook_theme. I tried using this hook_theme to call the theme function:

function xray_theme() {
  return array(
    'appearance_summary' =&gt; array(
      'variables' =&gt; array(
        'themes' =&gt; NULL,
        'attr' =&gt; NULL,
      ),
    ),
  );
}


The theme function takes two variables $themes &amp; $attr so I put both of those in. But I get the error.

Notice: Array to string conversion in menu_get_active_help() (line 1722 of C:\XAMPP\htdocs\drupal\includes\menu.inc).

Am I misunderstanding hook_theme?

function theme_xray_appearance_summary($variables) {
  $themes = $variables['data']['themes'];
  // Collapse attributes for paragraph tag to a string.
  $attr = drupal_attributes($variables['attributes']);

$output = '';
  $output .= "&lt;p $attr&gt;";
  $output .= t('This site');
  $output .= ' ';
  $output .= format_plural(
    $themes['num_themes'] - $themes['num_hidden'],
    'has only one theme available',
    'has @count themes available'
  );
  $output .= ' ';
  $output .= format_plural(
    $themes['num_hidden'],
    'plus one hidden theme.',
    'plus @count hidden themes.'
  );
  $output .= ' ';
  $output .= t('Of the non-hidden themes,');
  $output .= ' ';
  $output .= format_plural(
    $themes['num_enabled'],
    'one is enabled.  The enabled theme',
    '@count are enabled.  In the enabled themes,'
  );
  $output .= ' ';
  $summaries = array();
  foreach ($themes['summaries'] as $name =&gt; $info) {
    $summary = '';
    $summary .= $name . ' ';
    $summary .= format_plural(
      $info['regions'],
      'has one region',
      'has @count regions'
    );
    if ($info['overlay_regions'] || $info['regions_hidden']) {
      $summary .= ' ' . t('(including') . ' ';
      $summary .= format_plural(
        $info['overlay_regions'],
        'one overlay region',
        '@count overlay regions'
      );
      $summary .= ' ' . t('and') . ' ';
      $summary .= format_plural(
        $info['regions_hidden'],
        'one hidden region',
        '@count hidden regions'
      );
      $summary .= ')';
    }
    $summaries[] = $summary;
  }
  $output .= xray_oxford_comma_list($summaries);
  $output .= '.';
  $output .= '&lt;/p&gt;';
  return $output;
}


EDIT ONE.

I've got rid of the error by changing the switch; thanks to Yuriy, but nothing still displays:

 case 'admin/appearance':
      $variables = array('data' =&gt; xray_appearance_summary());
      return theme('xray_appearance_summary', $variables);
First of all, your theme_xray_appearance_summary should be theme_appearance_summary, and should take $variables by reference: &amp;$variables.

Second of all, hook_help() expects you to return a string, but your implementation returns the data from xray_appearance_summary(), which returns an array, thus the error you're getting.