You are here

function hook_sbp_details in Search by Page 6

Same name and namespace in other branches
  1. 7 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

  • 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 component 'title' (the page title) and optional component 'content' (an override of the page content, to avoid standard Drupal rendering).
  • If keywords are not null, return an associative array of fields suitable for display on search results screen for this path. See the Drupal documentation for hook_search() for a list of what the fields are. The 'title' component must be given. The 'link' component should be omitted (it is handled by the main search_by_page module). The search_by_page_excerpt() function may be useful in extracting a 'snippet'.

See also

hook_sbp_paths()

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
Implementation of Search by Page hook_sbp_details().
sbp_nodes_sbp_details in ./sbp_nodes.module
Implementation of Search by Page hook_sbp_details().
sbp_paths_sbp_details in ./sbp_paths.module
Implementation of Search by Page hook_sbp_details().
sbp_users_sbp_details in ./sbp_users.module
Implementation of Search by Page hook_sbp_details().
2 invocations of hook_sbp_details()
search_by_page_update_index in ./search_by_page.module
Implementation of hook_update_index().
_search_by_page_do_search in ./search_by_page.module
Internal function: performs a search, for hook_search($op = 'search').

File

./search_by_page.api.php, line 127
Search by Page module API.

Code

function hook_sbp_details($id, $environment, $keys = NULL) {
  $node = my_module_get_node($id);
  return array(
    'type' => check_plain(node_get_types('name', $node)),
    'title' => search_by_page_strip_tags($node->title, $environment),
    'user' => theme('username', $node),
    'date' => $node->changed,
    'extra' => $node->extra,
    'snippet' => search_by_page_excerpt($keys, search_by_page_strip_tags($node->body, $environment)),
  );
}