I have a custom table that contains data related to certain nodes. I'm using EVA (Entity Views Attachment) to display some of this data along with the node, which works great.

However, I now want to display a single value from a related table when viewing a node.

I guess this could also be done using EVA, but creating a view to output a single value seems like the wrong approach(?)

In this case, the table does not contain entities. It is defined using hook_schema(), and made available to views with hook_views_data () in Drupal 7.

Thanks for any thoughts on the best way to proceed.

1 Answer 1


there is surprisingly many ways to acheive it :) this is one that will require some work, but should be sane and scalable :

  • in a hook_node_load, load the data and attach it to the $node ($node->my-data)
  • [optionally] in hook_preprocess_node, create a variable for the template
  • in your template file, show the value aproprietly
  • Thanks, this is helpful. Is it possible to expose the value retrieved using hook_node_load as a field under Manage Display? It's not essential, I'm just curious.
    – Dave Bruns
    Dec 9, 2012 at 20:38
  • ie with display suite you can add a "code field"
    – mojzis
    Dec 9, 2012 at 21:20
  • this one might be even better hook_node_view
    – mojzis
    Dec 10, 2012 at 19:16

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.