How to add element not appearing on the page via node_view_alter? Given the following code:

function mymodule_node_view_alter(&amp;$build) {
  $node = $build['#node'];
  if ($node-&gt;type != 'podcasts') {
    return;
  }

  $build['new_section'] = array(
    '#weight' =&gt; 15,
    '#markup' =&gt; 'test injected data'
  );

  dpm($build);
}


In the dpm() output, I can see that my test data is in the array; however, nothing shows up on-screen.



Do I need to pre-define this new section or set it to allow any new sections?
hook_node_view_alter() documentation reads: 


  This hook is called after the content has been assembled in a
  structured array and may be used for doing processing which requires
  that the complete node content structure has been built.


This means it is for logic that fires after the render array has been constructed, eg changing weights or items in the array you cannot control (items from other modules).

What you are looking for is hook_node_view(). That should allow you to add new sections into a render array.

The example from the linked resource:

function hook_node_view($node, $view_mode, $langcode) {
  $node-&gt;content['my_additional_field'] = array(
    '#markup' =&gt; $additional_field,
    '#weight' =&gt; 10,
    '#theme' =&gt; 'mymodule_my_additional_field',
  );
}