tags:

views:

72

answers:

1

I have a custom module that returns data from a web service call. It comes back from an XML response, which I am converting to an array.

Once I have the array, I do:

$output = theme('search_srs_results', $data);
return $output;

But I am getting a white screen. No apache/php/watchdog errors.

I've done this before in another module without any difficulty. My theme hook is defined, and points to a template file, passing the $data argument. If I dump $output before it's returned, its NULL.

$data definitely has a populated array before being themed.

If I do theme('item_list', $data);, it renders, no white screen.

I tried reading the docs again on hook_theme and theme() but I don't seem to be doing anything wrong.

Here are the theme functions:

/**
 * Implementation of hook_theme()
 */

function srs_finder_theme() {
  return array(
    'search_srs_results' => array(
      'template' => 'srs-finder-results',
      'arguments' => array('data' => null),
    ),
  );
}

/**
 * Implementation of hook_preprocess()
 */

function srs_finder_preprocess_search_srs_results(&$vars) {
  $data = $vars['data'];
}

Whats missing?

+1  A: 

I don't understand why you need hook_preprocess() function at all. $data should automatically be available to srs-finder-results.tpl.php. Thats because you're passing this variable in the call theme('src_src_results', $data) and the fact that you have declared that there is 1 argument in hook_theme().

srs-finder-results.tpl.php file should reside in the src_finder module folder. You need to implement the code for that! (Alternatively as nikit has commented above, provide a theme_search_srs_results function. In that case you will need to remove the template array entry)

[Note: If other users of the module want to override this theme template they can always provide their own implementation of srs-finder-results.tpl.php in the theme folder of the theme that is active.]

Sid NoParrots
Already did all that. I guess it was Drupal caching issue, it started working after making sure it was off and clearing it a few times.
Kevin

related questions