I wrote a hook like so:
function john_page_build(&$page)
{
$akeys = array_keys($page['content']['system_main']['nodes']);
print $akeys[0];
}
On pages with urls like http://mysite.com/page/43
, it will print the node id for that page. However, on a page with url like http://mysite.co/page/43/done?sid=2
, drupal gives a warning saying that $page['content']['system_main']['nodes']
does not exist.
Is there a consistent way to get the node id WITHOUT parsing the url?