0

I have three things:

  • A user (User entity)

  • A league (Node)

  • A league entry (Node, with a numerical field for time and a noderef field to a league)

A user can create a league entry node, and set a time value and a node reference to a league node.

I want to produce a view that takes the league node id as an argument, and produces a table row for each user that has submitted a league entry node. The columns will be the user name, a user field that states the user's team, and finally, for every league entry node raised by them as author, that contains a node reference to the current league nid, a sum of the matching league entries numerical fields.

Now as you can imagine, doing this in views is very problematic because of aggregation issues on a single field; so a simpler alternative is to simple create a new DB table that stores the data I want to display in distinct fields.

So if I have a DB table like:

username, league, total of league entry nodes time value so far

How can I get this info into views so I can take advantage of table display, column sorting, and all that good stuff?

1

There are a couple of ways of doing this. You can create an entity. This requires the writing of a custom module to do so. Entities can be challenging if you have never done them before.

Another way and slightly simpler (still requires a custom module). Is to use the Views API. The first thing you would implement is hook_views_data(). This is a really good example of hook_views_data borrowed from Drupal Commerce.

Lastly, there are some modules out there that might help. One of them is Schema Views.

  • That's loads of entrypoints, thank you! I can go from here :) – njp Jan 31 '15 at 11:22

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.