Drupal 9 Get Nid From Node

[Solved] Drupal 9 Get Nid From Node | Php Frameworks Drupal - Code Explorer | yomemimo.com
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

Answers related to drupal 9 get nid from node

Code Explorer Popular Question For Php Frameworks Drupal