logo

Get node id of current node page Drupal 10

04
September

Get node id of current node page Drupal 10
By: Anonymous | Published On: Wed, 09/04/2024 - 12:11

	$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();
	}

Need Help ?