Drupal – Get node id from URL

$nid = explode(“/”, $_SERVER[‘REQUEST_URI’]);
$nid = end($nid);
echo “Node id:”.$nid;

About selvam4win

I am Selvam. I am very jolly person and frank one.

Posted on October 20, 2010, in Drupal, Node id. Bookmark the permalink. 4 Comments.

  1. echo “Node id:”.arg(1);

  2. It solves problem when we have a classic link (node/12), but how I get a node id when I have alias for node (/contact.html) ?

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: