function node_is_page
Same name in other branches
- 7.x modules/node/node.module \node_is_page()
- 8.9.x core/modules/node/node.module \node_is_page()
- 10 core/modules/node/node.module \node_is_page()
- 11.x core/modules/node/node.module \node_is_page()
Checks whether the current page is the full page view of the passed-in node.
Parameters
\Drupal\node\NodeInterface $node: A node entity.
Return value
int|false The ID of the node if this is a full page view, otherwise FALSE.
3 calls to node_is_page()
- book_node_links_alter in core/
modules/ book/ book.module - Implements hook_node_links_alter().
- statistics_node_view in core/
modules/ statistics/ statistics.module - Implements hook_ENTITY_TYPE_view() for node entities.
- template_preprocess_node in core/
modules/ node/ node.module - Prepares variables for node templates.
File
-
core/
modules/ node/ node.module, line 372
Code
function node_is_page(NodeInterface $node) {
$route_match = \Drupal::routeMatch();
if ($route_match->getRouteName() == 'entity.node.canonical') {
$page_node = $route_match->getParameter('node');
}
return !empty($page_node) ? $page_node->id() == $node->id() : FALSE;
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.