function hook_node_update_index
Same name in other branches
- 7.x modules/node/node.api.php \hook_node_update_index()
- 9 core/modules/node/node.api.php \hook_node_update_index()
- 8.9.x core/modules/node/node.api.php \hook_node_update_index()
- 10 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 loading, and after the result of rendering is added as $node->rendered to the node object.
Parameters
\Drupal\node\NodeInterface $node: The node being indexed.
Return value
string Additional node information to be indexed.
Related topics
1 function implements 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 core/
modules/ comment/ comment.module - Implements hook_node_update_index().
2 invocations of hook_node_update_index()
- NodeSearch::indexNode in core/
modules/ node/ src/ Plugin/ Search/ NodeSearch.php - Indexes a single node.
- NodeSearch::prepareResults in core/
modules/ node/ src/ Plugin/ Search/ NodeSearch.php - Prepares search results for rendering.
File
-
core/
modules/ node/ node.api.php, line 323
Code
function hook_node_update_index(NodeInterface $node) {
$text = '';
$ratings = \Drupal::database()->query('SELECT [title], [description] FROM {my_ratings} WHERE [nid] = :nid', [
':nid' => $node->id(),
]);
foreach ($ratings as $rating) {
$text .= '<h2>' . Html::escape($rating->title) . '</h2>' . Xss::filter($rating->description);
}
return $text;
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.