function hook_sbp_details in Search by Page 7
Same name and namespace in other branches
- 6 search_by_page.api.php \hook_sbp_details()
Return details about an indexed path (required sub-module hook).
This hook is invoked after a search, to get full information about what to display.
This hook is also invoked during search indexing to get the page title which is added to the indexed text. In this case, $keys will be null, and the module can also return rendered content to be indexed, if desired.
Parameters
$id: The ID corresponding to the path. This is the ID number you returned in hook_sbp_paths(), for this path.
$environment: ID of environment currently being indexed or searched.
$keys: The keywords being searched for (useful in extracting a snippet). NULL indicates this call is for search indexing.
Return value
One of the following:
- If for some reason this path should not be displayed or indexed, return NULL or zero.
- If $keys is NULL, return an associative array for search
indexing, with the following elements:
- title: Page title.
- content: (optional) Override of the page content, to avoid standard Drupal rendering.
- If $keys is not NULL, return an associative array of fields suitable
for display on the search results screen for this path. See the Core
documentation for hook_search() for a list of what the fields are. Some
notes on the fields:
- title: Required.
- link: Should be omitted (it is handled by the main search_by_page module.
- snippet: Suggested. See also search_by_page_excerpt().
- object: An object (such as node, user, or file object) related to the results.
See also
4 functions implement hook_sbp_details()
Note: this list is generated by pattern matching, so it may include some functions that are not actually implementations of this hook.
- sbp_attach_sbp_details in ./
sbp_attach.module - Implements Search by Page hook_sbp_details().
- sbp_nodes_sbp_details in ./
sbp_nodes.module - Implements Search by Page hook_sbp_details().
- sbp_paths_sbp_details in ./
sbp_paths.module - Implements Search by Page hook_sbp_details().
- sbp_users_sbp_details in ./
sbp_users.module - Implements Search by Page hook_sbp_details().
2 invocations of hook_sbp_details()
- search_by_page_search_execute in ./
search_by_page.module - Implements hook_search_execute().
- search_by_page_update_index in ./
search_by_page.module - Implements hook_update_index().
File
- ./
search_by_page.api.php, line 131 - Search by Page module API.
Code
function hook_sbp_details($id, $environment, $keys = NULL) {
$node = my_module_get_node($id);
$type = node_type_get_type($node);
return array(
'type' => check_plain($type->name),
'title' => search_by_page_strip_tags($node->title, $environment),
'user' => theme('username', array(
'account' => $node,
)),
'date' => $node->changed,
'extra' => $node->extra,
'snippet' => search_by_page_excerpt($keys, search_by_page_strip_tags($node->body[LANGUAGE_NONE][0]['value'], $environment)),
);
}