Question : drupal 9 get nid from node
Answered by : blueeyed-booby-mmft5pkkhrpq
$node = \Drupal::routeMatch()->getParameter('node');
if ($node instanceof \Drupal\node\NodeInterface) { // You can get nid and anything else you need from the node object. $nid = $node->id();
}
Source : https://drupal.stackexchange.com/questions/145823/how-do-i-get-the-current-node-id | Last Update : Tue, 13 Jul 21