hook_view, hook_theme and Display suite My module adds further content to a specific node bundle, in the "view" phase, in the following way:


hook_view (under the right conditions) adds these "contents" to the node display array
hook_theme specifies how to render the possible render_array related to the added contents


I followed several tutorials about, and in effect the documentation (of the latter) reports: 


  The structure of $node->content is a renderable array as expected by
  drupal_render().


Here is an abstract from my code:

/**
 * Implements hook_view().
 * Remember: hook prefix is based on the base of the node type (node-type-specific hook)
 */
function mynode_view($node, $view_mode) {
  $contentWrapper = entity_metadata_wrapper('node', $node);
  $myfield = $contentWrapper-&gt;myfield-&gt;value();
  if ($view_mode=="full") {
    $node-&gt;content["ds_column"] = array(
      '#markup' =&gt; theme('ds_column', array(
        'element' =&gt; _mymodule_to_render_arrays($myfield, $node-&gt;status),
        )),
      '#weight' =&gt; 150,
    );
  }
  return $node;
}


As you can see this adds the ds_column to my node content, telling me it has to be rendered by a theme function.
It also passes to the theme function a "render array" (containing the information to be rendered).

/**
 * Implements hook_theme().
 */
function mymodule_theme($existing, $type, $theme, $path) {
  return array(
    'ds_column' =&gt; array(
      // See http://drupal.org/node/224333#theme_changes
      'variables' =&gt; array('element' =&gt; NULL),
      'template' =&gt; 'theme/ds_column'
    ),
  );
  return $theme;
}


This part of my module explain what template file have to be used in order to properly render, in the node (bundle) page, the content I added by the previous hook.

For what I see this is the standard approach. And indeed everything works fine.

The problem description starts here.

The module I described has been installed on an environment using the Display Suite module to define how to show contents for each node type in the node page, but the Display Suite module doesn't allow to see, in the configuration page, the content I added with the code shown above. So now that content doesn't appear in the node page.

I would like just to see the "ds_column" in the Display Suite configuration page for that specific node, in order to place it properly.

I can't figure how to see it (have I to implement also a DS hook? Have I to modify my code in some way?). I just found the "Display Suite Extra" sub-module, but I wasn't able to solve by it.
For people interested to the solution, you have to use the hook_field_extra_field() hook.

There you can declare your own "virtual fields" and they will appear as fields also in the Display Suite.

To link them to the content you create, just be sure to use the same name as a key both in the field name and in what you add as a node->content.

To provide you with the solution related to my example:

/**
 * Implements hook_field_extra_fields().
 */
function mymodule_field_extra_fields() {
  $extra['node']['my_custom_bundle_type']['display'] = array(
      'ds_column' =&gt; array(
        'label' =&gt; t('My column'),
        'description' =&gt; t('Description is also mandatory'),
        'weight' =&gt; 99,
      ),
  );
  return $extra;
}


As you can see ther key ds_column is the same used in the mynode_view (or in any other function implementing a hook able to modify the content render array).