10

It seems like the Display Suite module completely ignores hook_preprocess_node() and hook_process_node(). Is this the case?

If it is so, what is the way to make minor changes to the final rendering with access to all the node variables?

2 Answers 2

14

Display Suite does indeed hijack the node rendering to a point where the default preprocess functions may not be used.

The module comes with a set of its own preprocess functions that are documented in ds.api.php.

In this case, hook_ds_pre_render_alter() can be used instead of the hook_preprocess_node() to modify the output via the complete render array. Also, the $entity object is available with all values.

2
  • how can i get $enitity in this hook
    – Moby M
    Commented Aug 15, 2018 at 8:16
  • @MobyM you can find it in the variable $context["entity"]
    – Renrhaf
    Commented Nov 7, 2018 at 4:54
1

I was able to trigger it using hook_preprocess_ds_entity_view():

function mytheme_preprocess_ds_entity_view(&$variables) {
  $variables['node'] = $variables['content']['#node'];
  $variables['view_mode'] = $variables['content']['#view_mode'];

  mytheme_preprocess_node($variables);
}

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