In trying to learn about theming and alter hooks. I'm looking at the render array passed to hook_node_view_alter()
with the following code.
function hook_node_view_alter(&$build) {
dpm($build);
}
I want to set a variable based on $build['body']['#object']['vid'])
, but I get this error:
Fatal error: Cannot use object of type stdClass as array
I don't understand this error. Can someone explain it?
hook_node_view_alter
param is passed by reference. But of course you can create a variable like this$myVar = $build['body']['#object']['vid’];
given that thevid
is set. After that you have to integrate everything back to$build
in order for your hook to take in effect.