-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1
On 04 May 2005, at 11:07 AM, Gerhard Killesreiter wrote:
On Tue, 3 May 2005, Maykel Moya wrote:
I recently asked for a way to know the current viewed node, someone point me to global $node. The problem is that the variable is randomly available, sometimes it have the correct content, sometimes is empty.
This is probably a bug of Drupal core. I'm using CVS HEAD.
No, this is by design. $node is not a global variable.
I'm thinking using global $_menu['local tasks'] and do some tricky parsing to find out the current viewed node.
You can parse the url instead (arg(0) == 'node' && is_numeric(arg(1))).
Additionally .. you can retrieve the node using node_load (it caches internally.. )
so if ((arg(0) == 'node') && is_numeric(arg(1))) { $node = node_load(array('nid' => arg(1)); } will populate the node variable.
- -- Adrian Rossouw Drupal developer and Bryght Guy http://drupal.org | http://bryght.com