How do you determine a node's ID? I am using several programs that need the node ID to insert content (such as panels) and the only way to add content to the selected panel is to input the NID...

I can't find the NID anywhere, ried searching here, google etc under "how do i determine node id nid in drupal 6" but found nothing.

Seems like this should be something easily viewable when I click on content management but apparently not...

any help would be greatly appreciated.

TIA :)


nevets’s picture

Some programs allow for title (they use auto complete) as well as node (though not all).

By default nodes have a path of node/{nid} so if you visit the administer content list, look for the title and hover over it you can find the nid. If you are using alias, hover over the edit link (will be of the form node/{nid}/edit).

ScoutBaker’s picture

You could also check out the About This Node module.

Chris Einkauf’s picture

Here's some PHP code that should give you the Node ID of the node you're currently viewing...

print $nid;
nevets’s picture

Without context, $nid is not a meaningful variable. Where/how do you expect it to be set?

Chris Einkauf’s picture

I think I must have read his question too quickly and assumed he wanted to know how to get the ID for the node he was currently viewing, such as when he's inserting something into a node type's template that needs the Node ID of that node.

After re-reading his question, I realize my answer was pretty incomplete and out-of-context.

m_sabal’s picture

The way I read your post, it looks like you are trying to create node content automatically outside the Drupal framework, and are trying to make sure the node IDs are generated correctly. If this is correct, the node ID is automatically generated by the database (it's an auto-increment field), so this is something you don't have to worry about. If you are trying to modify existing content automatically, please provide us with step by step details of how you are determining which content needs to be changed, and how the program making the changes fits into the Drupal framework in your scenario.

bstrange’s picture

Actually, when using panels to make custom pages, it does not use node titles when inputing content into a given section of the panels; it only uses node ID. Being able to determine the node ID will allow me to put specific nodes in specific sections of the panel page.

bstrange’s picture

BTW, thanks to everyone for their replies. Nevets solution (mousing over edit) seemed the simple route and worked perfectly for identifing the node.

Thanks again :)

jaswanttak’s picture

You can use this snippet

function currentnode_nid(){
if (arg(0)=='node' && is_numeric(arg(1)))
return arg(1);
return 0;

function currentnode(){
return node_load(currentnode_nid());

it will return the current node id.

nevets’s picture

You can simplify that code to

$node = menu_get_object();
ronnqvist’s picture

Thank you so much! I looked for this all over the web. :) Everyone seem just to grab the node number from the URL, which is such an awkward way of passing data within a web application that I'd hesitate to admit using such a method. :)