0

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.

0

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
| improve this answer | |
  • 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 '12 at 20:38
  • ie with display suite you can add a "code field" – mojzis Dec 9 '12 at 21:20
  • this one might be even better hook_node_view – mojzis Dec 10 '12 at 19:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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