| 6 core.php | hook_search_page($results) |
| 7 search.api.php | hook_search_page($results) |
| 8 search.api.php | hook_search_page($results) |
Override the rendering of search results.
A module that implements hook_search_info() to define a type of search may implement this hook in order to override the default theming of its search results, which is otherwise themed using theme('search_results').
Note that by default, theme('search_results') and theme('search_result') work together to create an ordered list (OL). So your hook_search_page() implementation should probably do this as well.
Parameters
$results: An array of search results.
Return value
A renderable array, which will render the formatted search results with a pager included.
See also
search-result.tpl.php, search-results.tpl.php
Related topics
1 function implements hook_search_page()
1 invocation of hook_search_page()
File
- modules/
search/ search.api.php, line 272 - Hooks provided by the Search module.
Code
function hook_search_page($results) {
$output['prefix']['#markup'] = '<ol class="search-results">';
foreach ($results as $entry) {
$output[] = array(
'#theme' => 'search_result',
'#result' => $entry,
'#module' => 'my_module_name',
);
}
$output['suffix']['#markup'] = '</ol>' . theme('pager');
return $output;
}
Login or register to post comments
Comments
Is this hook only for modules
Is this hook only for modules that define their own search with hook_search_info()? or will it modify the page of any search results?
The hook will modify all
The hook will modify all search pages. At least that is what it does for me, and I have not implemented hook_search_info.