Getting the URL of a node in Drupal 7 Getting the URL of a node in Drupal 7 php php

Getting the URL of a node in Drupal 7


You can use the url() function:

$options = array('absolute' => TRUE);$nid = 1; // Node ID$url = url('node/' . $nid, $options);

That will give you the absolute path (i.e. with http://example.com/ in front of it), with the URL aliased path to the node page.


You can also try drupal_lookup_path('alias',"node/".$node->nid).


Also you can get it by

$path=drupal_get_path_alias('node/'.$nid);

absolute path for nid

url('node/' . $node->id(), ["absolute" => TRUE]);