Skip to main content
replaced http://drupal.stackexchange.com/ with https://drupal.stackexchange.com/
Source Link

Still comes through the URL indirectly, but this is the easiest way to get it: menu_get_object.

<?
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 discussionthis discussion for more detail.

Still comes through the URL indirectly, but this is the easiest way to get it: menu_get_object.

<?
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 for more detail.

Still comes through the URL indirectly, but this is the easiest way to get it: menu_get_object.

<?
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 for more detail.

Source Link
mohit_rocks
  • 4k
  • 2
  • 25
  • 60

Still comes through the URL indirectly, but this is the easiest way to get it: menu_get_object.

<?
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 for more detail.