Skip to main content
made a sentence clearer
Source Link
avpaderno
  • 97.9k
  • 15
  • 164
  • 284

Your hook_node_view() is incorrect, check the documentation and example implementations. The first argument is a $build array$build array.

  That's the new $node->content$node->content: What your code is adding to $node->content should be added to $build.

Also, never render things yourself.: Just put your render array ($node_statistics$node_statistics) in $build['content_statistics_list']$build['content_statistics_list'].

It's also recommended to implement hook_entity_extra_field_info()hook_entity_extra_field_info() and expose that key as an extra field. Then it can be shown/hidden based on the view mode.

Your hook_node_view() is incorrect, check the documentation and example implementations. The first argument is a $build array.

  That's the new $node->content.

Also, never render things yourself. Just put your render array ($node_statistics) in $build['content_statistics_list']

It's also recommended to implement hook_entity_extra_field_info() and expose that key as an extra field. Then it can be shown/hidden based on the view mode.

Your hook_node_view() is incorrect, check the documentation and example implementations. The first argument is a $build array. That's the new $node->content: What your code is adding to $node->content should be added to $build.

Also, never render things yourself: Just put your render array ($node_statistics) in $build['content_statistics_list'].

It's also recommended to implement hook_entity_extra_field_info() and expose that key as an extra field. Then it can be shown/hidden based on the view mode.

Source Link
Berdir
  • 83.5k
  • 6
  • 161
  • 207

Your hook_node_view() is incorrect, check the documentation and example implementations. The first argument is a $build array.

That's the new $node->content.

Also, never render things yourself. Just put your render array ($node_statistics) in $build['content_statistics_list']

It's also recommended to implement hook_entity_extra_field_info() and expose that key as an extra field. Then it can be shown/hidden based on the view mode.