function hook_node_update_index

Same name in other branches
  1. 9 core/modules/node/node.api.php \hook_node_update_index()
  2. 8.9.x core/modules/node/node.api.php \hook_node_update_index()
  3. 10 core/modules/node/node.api.php \hook_node_update_index()
  4. 11.x core/modules/node/node.api.php \hook_node_update_index()

Act on a node being indexed for searching.

This hook is invoked during search indexing, after node_load(), and after the result of node_view() is added as $node->rendered to the node object.

Parameters

$node: The node being indexed.

Return value

string Additional node information to be indexed.

Related topics

2 functions implement hook_node_update_index()

Note: this list is generated by pattern matching, so it may include some functions that are not actually implementations of this hook.

comment_node_update_index in modules/comment/comment.module
Implements hook_node_update_index().
search_node_update_index in modules/search/search.module
Implements hook_node_update_index().
4 invocations of hook_node_update_index()
hook_search_execute in modules/search/search.api.php
Execute a search for a set of key words.
hook_update_index in modules/search/search.api.php
Update the search index for this module.
node_search_execute in modules/node/node.module
Implements hook_search_execute().
_node_index_node in modules/node/node.module
Indexes a single node.

File

modules/node/node.api.php, line 738

Code

function hook_node_update_index($node) {
    $text = '';
    $comments = db_query('SELECT subject, comment, format FROM {comment} WHERE nid = :nid AND status = :status', array(
        ':nid' => $node->nid,
        ':status' => COMMENT_PUBLISHED,
    ));
    foreach ($comments as $comment) {
        $text .= '<h2>' . check_plain($comment->subject) . '</h2>' . check_markup($comment->comment, $comment->format, '', TRUE);
    }
    return $text;
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.