Enable Devel's Execute PHP block (in the footer). The node resulting from dpm(menu_get_object()); has a rendered body, whereas an execution of dpm(node_load(arg(1))); returns the node with the original body from the database.
Enable Devel's Execute PHP block (in the footer). The node resulting from dpm(menu_get_object()); has a rendered body, whereas an execution of dpm(node_load(arg(1))); returns the node with the original body from the database.
Comments
Comment #1
salvisAccording to http://drupal.org/node/114774#menu_get_object (and to Coder),
node_load(arg(1))ought to be replaced withmenu_get_object()but the body returned by the latter is unusable.Comment #2
mile23Have you investigated the Views module?
Comment #3
salvisWhy? This is a core-only issue.
Comment #4
mile23Well, if you're trying to put a node in a block, you can accomplish that and quite a few other things with Views.
If you're trying to modify the $node object before rendering then hook_nodeapi() with 'view' or 'load', or perhaps hook_view() is what you want.
Basically it's unclear what you're trying to do, which is why it's hard to address the problem.
Comment #5
salvisThank you for trying to help, but this is not the point. hook_nodeapi('load') might have been a possible alternative at the time, but node_load(arg(1)) worked just fine.
I don't have the actual context anymore, but it doesn't really matter. We were calling a core function from a custom module and that core function didn't deliver what it promised.
If
menu_get_object()is supposed to replacenode_load(arg(1))then it should deliver at least as much as the latter does.The latter gives an unrendered body and this is what we needed, because we wanted to modify and re-save it. We weren't looking for a work-around, but we were reporting a core bug. I realize that menu_get_object() cannot be fixed anymore without risking to break code that relies on its misbehavior, but D6 should have an alternative that really delivers what http://drupal.org/node/114774#menu_get_object promises.
Comment #6
igorik commentedany progress here? it sounds like it can't be really replace of node_load() while it has this different behaviour.