node_is_page(NodeInterface $node)
Checks whether the current page is the full page view of the passed-in node.
\Drupal\node\NodeInterface $node: A node entity.
int|false The ID of the node if this is a full page view, otherwise FALSE.
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); }
© 2001–2016 by the original authors
Licensed under the GNU General Public License, version 2 and later.
Drupal is a registered trademark of Dries Buytaert.
https://api.drupal.org/api/drupal/core!modules!node!node.module/function/node_is_page/8.1.x