node_is_page

node_is_page(NodeInterface $node)

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.

File

core/modules/node/node.module, line 482
The core module that allows content to be submitted to the site.

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);
}
doc_Drupal
2016-10-29 09:31:54
Comments
Leave a Comment

Please login to continue.