views:

192

answers:

2

I am trying to display a custom page the same as my search results page by re-using the theme functions and pre-processors built into the search module.

With an empty Drupal cache this works beautifully. I simple call

theme('search_results', $results, 'node' );

with a correctly popuated results array, and I get back formatted markup. Great.

However, when the cache is not clear, the search module is not available and so the theme() call goes nowhere and returns an empty string.

I've tried drupal_load('module','search') which makes the module file available, but does not intialize its hook_theme.

A: 

Fixed it with the following:

function_exists('search_theme') or drupal_load('module','search');
function_exists('template_preprocess_search_results') or module_load_include('inc','search','search.pages');

I don't like it though.

Tim Whitlock
both drupal_load and module_load_include can be run more than once so you don't need the function_exists. Also make sure that your define a dependency with search in your module.
Jeremy French
A: 

For theming standart search results use these: http://api.drupal.org/api/drupal/modules--search--search-result.tpl.php/6 http://api.drupal.org/api/drupal/modules--search--search-results.tpl.php/6

Nikit