Example #1
0
/**
 * 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.
 *
 * @param $id
 *    The ID corresponding to the path. This is the ID number you
 *    returned in hook_sbp_paths(), for this path.
 * @param $environment
 *   ID of environment currently being indexed or searched.
 * @param $keys
 *    The keywords being searched for (useful in extracting a snippet). NULL
 *    indicates this call is for search indexing.
 *
 * @return
 *    - 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 hook_sbp_paths()
 */
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)));
}
Example #2
0
/**
 * 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.
 *
 * @param $id
 *    The ID corresponding to the path. This is the ID number you
 *    returned in hook_sbp_paths(), for this path.
 * @param $environment
 *   ID of environment currently being indexed or searched.
 * @param $keys
 *    The keywords being searched for (useful in extracting a snippet). NULL
 *    indicates this call is for search indexing.
 *
 * @return
 *    - 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 hook_sbp_paths()
 */
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)));
}