Skip to main content

Hook node_view and content

I was trying to remove some field collection items (with default values but only for one subfield) from a node and although everything was working fine nothing was changing. So what was i doing wrong then? Well there a "small" catch that it is not clear about the node object that is rendered inside the node_view hook. What is that? It is the $node->content array that holds all the about to be rendered elements. So if you change the $node->field_custom_a values nothing happens but if you change the $node->content['field_custom_a'] there it is! Hope that helps someone, someday :)

alter node display