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->myfield->value();
  if ($view_mode=="full") {
    $node->content["ds_column"] = array(
      '#markup' => theme('ds_column', array(
        'element' => _mymodule_to_render_arrays($myfield, $node->status),
      '#weight' => 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' => array(
      // See http://drupal.org/node/224333#theme_changes
      'variables' => array('element' => NULL),
      'template' => '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.

  • Welcome to Drupal Answers! It's not clear what you are saying, mostly because you are using a non-standard terminology and you aren't showing the code of your module. Without seeing any code, it's not possible to tell you if you need to change your code, which is one of the questions you are asking.
    – apaderno
    Apr 28, 2017 at 12:33
  • Please check my edit of your question, trying to help you to improve it a bit (and fix some typos). Feel free to further adapt, and if you don't like my edit at all, just perform a rollback. Good luck! PS: don't worry about anonymous downvotes ... (only consider those that teach you what you need to do to improve/rework it somehow). Apr 28, 2017 at 17:09
  • Thank you @Pierre.Vriens I hope the question will be un-"on hold"ed and someone can help me. :) Apr 28, 2017 at 17:15

1 Answer 1


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' => array(
        'label' => t('My column'),
        'description' => t('Description is also mandatory'),
        'weight' => 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).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.