diff options
author | Dries Buytaert <dries@buytaert.net> | 2010-01-06 14:07:50 +0000 |
---|---|---|
committer | Dries Buytaert <dries@buytaert.net> | 2010-01-06 14:07:50 +0000 |
commit | 4be3e772fcb03a2a75c171afb19dd55fdc170c5a (patch) | |
tree | 076a8f5a6d6fa048d8f7430cc3b34518f9196b2c /modules | |
parent | 26574bd51e1de982a1f3f806d5a527ccb94ae3df (diff) | |
download | brdo-4be3e772fcb03a2a75c171afb19dd55fdc170c5a.tar.gz brdo-4be3e772fcb03a2a75c171afb19dd55fdc170c5a.tar.bz2 |
- Patch #171317 by jhodgdon, fgm, CitizenKane: hook_search_page() not appearing on api.drupal.org.
Diffstat (limited to 'modules')
-rw-r--r-- | modules/search/search.api.php | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/modules/search/search.api.php b/modules/search/search.api.php index 2a4919105..2912b30f7 100644 --- a/modules/search/search.api.php +++ b/modules/search/search.api.php @@ -25,6 +25,9 @@ * using a key:value syntax. This allows all search queries to have a clean * and permanent URL. See node_form_search_form_alter() for an example. * + * You can also alter the display of your module's search results + * by implementing hook_search_page(). + * * The example given here is for node.module, which uses the indexed search * capabilities. To do this, node module also implements hook_update_index() * which is used to create and maintain the index. @@ -203,6 +206,39 @@ function hook_search_execute($keys = NULL) { return $results; } +/** + * Override the rendering of search results. + * + * A module that implements hook_search() 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 a definition + * list. So your hook_search_page() implementation should probably do + * this as well. + * + * @see search-result.tpl.php, search-results.tpl.php + * + * @param $results + * An array of search results. + * @return + * An HTML string containing the formatted search results, with + * a pager included. + */ +function hook_search_page($results) { + $output = '<dl class="search-results">'; + + foreach ($results as $entry) { + $output .= theme('search_result', $entry, $type); + } + $output .= '</dl>'; + $output .= theme('pager', NULL); + + return $output; +} + /** * Preprocess text for the search index. * |