logo

Get URL by Node id Drupal 8

22
November

Get URL by Node id Drupal 8
By: Anonymous | Published On: Mon, 11/22/2021 - 17:31

you have to use following class

Drupal\Core\Url

You can use folowing code to get URL Alias

		$options = ['absolute' => TRUE];
		$url = \Drupal\Core\Url::fromRoute('entity.node.canonical', ['node' => $nid], $options);
		$nodeurl = $url->toString();

Need Help ?