By zaccb on
I'm trying to manipulate field values based on a condition evaluated every time a node is loaded. Attempting to affect these values using using hook_node_view() but the changes aren't reflected in the resulting $content array.
Comments
That's because $node->content
That's because $node->content doesn't exist yet, and is overwritten when it's actually created. It's created in this line:
Which happens in node_build_content(), which in turn is called from node_view().
If you want to add something to $node->content(), you should be doing it in hook_node_view().
Contact me to contract me for D7 -> D10/11 migrations.
I ended up implementing my
I ended up implementing my changes in
hook_node_view()but the$content[]array was unaffected.I had to explicitly call
node_build_content()inside the hook.Is this already happening in
node_view()?That doesn't make sense, your
That doesn't make sense, your changes should be reflected. Maybe try this:
Contact me to contract me for D7 -> D10/11 migrations.