You are here

function hook_sbp_paths in Search by Page 7

Same name and namespace in other branches
  1. 6 search_by_page.api.php \hook_sbp_paths()

Return a list of pages to be indexed (required sub-module hook).

This hook is invoked whenever Search is building/adding to its index (usually during a cron run).

Parameters

$environment: ID of environment currently being indexed.

Return value

Associative array of path items. The array keys are the paths to be indexed. Each value is an array, with the following components:

  • 'id': ID number (unsigned integer) for module to reference this path. This is passed into the module's hook_sbp_details() implementation when Search by Pages needs information about the page.
  • 'languages': Language codes to use to index this path. The page will be rendered in each language during the indexing process, and indexed separately for each language. Do not include the language prefix in the path. Must include at least one language.
  • 'role': ID of role to use when indexing this path. The page will be rendered as if being viewed by a user with this role's permissions (or not indexed at all if that role cannot view the page), and all visible text will be indexed and available for searching. Permissions will still be checked when displaying search results, however.
  • 'min_time' (default 1): Minimum time to wait to reindex this item, in seconds. Search by Page cycles through and reindexes items, because they are rendered through the theme, and it is assumed that rendering may depend on other content that can change. Each cron run, it first indexes any items that are new or have been marked as needing reindexing. Then it reindexes the oldest other items in its index, up to the cron throttle limit. However, no item will be reindexed before this minimum index time has been exceeded. Set to 0 for items that should only be indexed once and never reindexed unless search_by_page_force_reindex() is called.
  • 'max_time' (default 0): Maximum time to wait to reindex this item, in seconds. This effectively marks the item as needing immediate reindexing after this much time has passed. Set to 0 for items that do not need this to happen. See 'min_time' entry above for more details on reindexing.

See also

hook_sbp_details()

4 functions implement hook_sbp_paths()

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_paths in ./sbp_attach.module
Implements Search by Page hook_sbp_paths().
sbp_nodes_sbp_paths in ./sbp_nodes.module
Implements Search by Page hook_sbp_paths().
sbp_paths_sbp_paths in ./sbp_paths.module
Implements Search by Page hook_sbp_paths().
sbp_users_sbp_paths in ./sbp_users.module
Implements Search by Page hook_sbp_paths().
1 invocation of hook_sbp_paths()
_search_by_page_rebuild_all_paths in ./search_by_page.module
Internal function: rebuilds the paths table for all modules.

File

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

Code

function hook_sbp_paths($environment) {
  return array(
    'my/drupal/path' => array(
      'id' => 1234,
      'languages' => array(
        'en',
        'es',
      ),
      'role' => DRUPAL_ANONYMOUS_RID,
    ),
  );
}