Php – Drupal theme() problem

drupaldrupal-6PHP

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.

Best Answer

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.

Related Topic