function hook_node_links_alter in Zircon Profile 8
Same name and namespace in other branches
- 8.0 core/modules/node/node.api.php \hook_node_links_alter()
Alter the links of a node.
Parameters
array &$links: A renderable array representing the node links.
\Drupal\node\NodeInterface $entity: The node being rendered.
array &$context: Various aspects of the context in which the node links are going to be displayed, with the following keys:
- 'view_mode': the view mode in which the node is being viewed
- 'langcode': the language in which the node is being viewed
See also
\Drupal\node\NodeViewBuilder::renderLinks()
\Drupal\node\NodeViewBuilder::buildLinks()
Entity CRUD, editing, and view hooks
Related topics
3 functions implement hook_node_links_alter()
Note: this list is generated by pattern matching, so it may include some functions that are not actually implementations of this hook.
- book_node_links_alter in core/
modules/ book/ book.module - Implements hook_node_links_alter().
- comment_node_links_alter in core/
modules/ comment/ comment.module - Implements hook_node_links_alter().
- statistics_node_links_alter in core/
modules/ statistics/ statistics.module - Implements hook_node_links_alter().
File
- core/
modules/ node/ node.api.php, line 489 - Hooks specific to the Node module.
Code
function hook_node_links_alter(array &$links, NodeInterface $entity, array &$context) {
$links['mymodule'] = array(
'#theme' => 'links__node__mymodule',
'#attributes' => array(
'class' => array(
'links',
'inline',
),
),
'#links' => array(
'node-report' => array(
'title' => t('Report'),
'href' => "node/{$entity->id()}/report",
'query' => array(
'token' => \Drupal::getContainer()
->get('csrf_token')
->get("node/{$entity->id()}/report"),
),
),
),
);
}