Views isn't pulling custom field correctly I've been developing a custom module, which uses the node id, with the rate module, to output the results to a simple mathematical equation (which uses the rate module - i.e. voting api) to calculate the total number of votes.

The calculation is completed as part of hook_field_formatter_view for the field. It is then passed through to the node's display.

The issue arises when passing through this same value to a Views output. It seems the node id isn't passing through to the field, which renders this whole problem impossible. I have been using this to access the node id:

  $node = menu_get_object();
  $nid = $node-&gt;nid; 


Which is then used to retrieve the necessary values from the database for the calculation. However, all fields are returning 0 (null) values in the views output.

Is this because the node id is not passing through, or could it be something else?
When using menu_get_object(), you'll get the node currently displayed from the menu. So for example, if you're on a page with a path like node/123, it will load the node with nid "123" (source). So that won't work inside a views for sure.

You should be able to retrieve the nid from the $entity element, which should be a parameter of your hook_field_formatter_view (as described here).