Still comes through the URL indirectly, but this is the easiest way to get it: [menu_get_object][1]. <? if ($node = menu_get_object()) { $nid = $node->nid; } ?> Note that if there is a node, it was already loaded by the menu system anyway and this is loaded from the static cache. Refer [this discussion][2] for more detail. [1]: http://api.drupal.org/api/drupal/includes%21menu.inc/function/menu_get_object/7 [2]: https://drupal.stackexchange.com/questions/38779/get-nodeid-in-drupal/38780#38780