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.
I'm thinking using global $_menu['local tasks'] and do some tricky parsing to find out the current viewed node.
My goal is to have selectively content shown in themes based on the owner of the current viewed node, that's why I inevitably need to know the current node.
Thanks in advance for any hint.
Regards, maykel
--
,''`. Maykel Moya : :' : http://moya.latertulia.org/ `. `' `- Debian GNU/Linux, the Free OS http://www.debian.org/
Op woensdag 04 mei 2005 03:44, schreef Maykel Moya:
My goal is to have selectively content shown in themes based on the owner of the current viewed node, that's why I inevitably need to know the current node.
Well, if you are not viewing a node, $node is not available, or incorrect. Does that hlep you? Regards, Bèr
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))).
Cheers, Gerhard
-----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