Add node ID to template variables is there any way to add node ID (if it exists) to template variables using

my_theme_preprocess_page(&amp;vars) function?


It looks like theme theme isn't using my_theme_preprocess_node(&amp;$vars, $hook) so I assume that node object isnt available in vars for my_theme_preprocess_page(&amp;vars).

It's not my website so I don't really know the structure.
If you want to access nid inside preprocess_page you should try something like this

arg(0) will return 'node' and arg(1) will return node nid.

Provided you must be inside a node.

if (arg(0) == 'node' &amp;&amp; is_numeric(arg(1))) {
  $nid = arg(1);
  if ($nid) {
   $node = node_load($nid);
   // creating the node variable
   $vars['node'] = node_load(arg(1), NULL, TRUE); 
  }
}