function hook_contextual_links_view_alter
Same name in other branches
- 7.x modules/contextual/contextual.api.php \hook_contextual_links_view_alter()
- 9 core/modules/contextual/contextual.api.php \hook_contextual_links_view_alter()
- 8.9.x core/modules/contextual/contextual.api.php \hook_contextual_links_view_alter()
- 10 core/modules/contextual/contextual.api.php \hook_contextual_links_view_alter()
Alter a contextual links element before it is rendered.
This hook is invoked by \Drupal\contextual\Element\ContextualLinks::preRenderLinks(). The renderable array of #type 'contextual_links', containing the entire contextual links data that is passed in by reference. Further links may be added or existing links can be altered.
Parameters
$element: A renderable array representing the contextual links.
$items: An associative array containing the original contextual link items, as generated by \Drupal\Core\Menu\ContextualLinkManagerInterface::getContextualLinksArrayByGroup(), which were used to build $element['#links'].
See also
hook_contextual_links_plugins_alter()
\Drupal\contextual\Element\ContextualLinks::preRenderLinks()
Related topics
1 function implements hook_contextual_links_view_alter()
Note: this list is generated by pattern matching, so it may include some functions that are not actually implementations of this hook.
- contextual_test_contextual_links_view_alter in core/
modules/ contextual/ tests/ modules/ contextual_test/ contextual_test.module - Implements hook_contextual_links_view_alter().
1 invocation of hook_contextual_links_view_alter()
- ContextualLinks::preRenderLinks in core/
modules/ contextual/ src/ Element/ ContextualLinks.php - Pre-render callback: Builds a renderable array for contextual links.
File
-
core/
modules/ contextual/ contextual.api.php, line 34
Code
function hook_contextual_links_view_alter(&$element, $items) {
// Add another class to all contextual link lists to facilitate custom
// styling.
$element['#attributes']['class'][] = 'custom-class';
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.