After upgrading to 5.10, I noticed a problem in my template. Calling a node via node_load ceased working. This line now returns empty:


$thisnode = node_load(array('nid'=>$node->nid));   

I finally tracked down this workaround which does in fact return the node data:


if ( arg(0) == 'node' && is_numeric(arg(1)) ) { $nodeid = arg(1); }

$thisnode = node_load($nodeid); 

I'm not 100% certain the break came with the 5.10 upgrade. Anybody else know for sure what might have broken "$node->nid"?

Comments

nevets’s picture

Where (what context) are you using $node->nid?

theropodx’s picture

Well the immediate context is the first code snippet i posted above. This code was in the body of my chameleon-derived template file. The purpose of the code is to discover what content type the node is and then hide or show the node title based on the content type. Works fine now, and worked fine before. Just wondering what broke the original code.

theropodx’s picture

just found out it was actually 5.8 that broke this. still not sure what changed.

okday’s picture

subscribing

Dave Reid’s picture

In your first code segment, I'm not sure why you would need to use node_load if you already have the $node variable. I would think you would want to do something like:

$thisnode = (arg(0) == 'node' && is_numeric(arg(1)) ? node_load(arg(1)) : FALSE);

or a little easier to understand:

$thisnode = FALSE;
if (arg(0) == 'node' && is_numeric(arg(1))) {
  $thisnode = node_load(arg(1));
}