0
votes

I have created a customized theme called "test", and I am trying to display the search results.

I added the function test_preprocess_search_results() to the template.php (copied the code from drupal page "function template_preprocess_search_results", then copy the search-result.tpl.php from search module to the "test"'s template folder.

function test_preprocess_search_results(&$variables) { $variables['search_results'] = ''; if (!empty($variables['module'])) { $variables['module'] = check_plain($variables['module']); } foreach ($variables['results'] as $result) { $variables['search_results'] .= theme('search_result', array('result' => $result, 'module' => $variables['module'])); } $variables['pager'] = theme('pager', array('tags' => NULL)); $variables['theme_hook_suggestions'][] = 'search_results__' . $variables['module']; }

I am new in drupal, my concern is how can I make the search result display in some certain div which claimed in my page.tpl.php file? Do something like <?php print render($page['search_result']); ?> in page.tpl.php div ? I am not sure how does the default theme know where to display the search result? Can anyone help thanks

ps: after what I did, and refresh the cache, nothing show up

1

1 Answers

1
votes

For search results you should use the search-results.tpl.php (all results list) and search-result.tpl.php (single list item) templates. Copy them from ROOT/modules/search folder into your theme folder and override them as you prefer.