nodefamily & views integration, status

Submitted by fago on Tue, 07/25/2006 - 12:25
In the last days I was working on the views integration for the nodefamily module. Unfortunately it turned out to be more complex than I thought originally. What I wanted to do, was that views is able to automatically join the node tables of different nodes together, so that one is able to list information of both nodes. But I noticed that this approach has some downsides. They are:
  • Joining two node tables with the help of a simple nid-nid relation is quite impossible to do, as views doesn't know which nid is which type and which fields belong to it.
  • So automatically joining with the help of the type information would be possible. However, this would have required patching of both CCK and views and further: Extending views to automatically join the node tables appropriate would be quite complex.
  • If a field of another content type would be added views would join the node table of this content type to be able to display its content, however if a field belongs to more than one content type which should views use for joining!?
So I thought about the whole thing a bit and came to another way to achieve the same feature. Joining of multiple views. (Makes only sense for tabular and list views..) This should work this way: The admin creates a view, example a userlisting using the usernode module. Then he creates a view of the profile content type (remember the nodeprofile module automatically sets a nodefamily relation between usernode and the profile content types, so there is a nodefamily relation). So then the admin edits the userlisting view and sets it to join to the profile-content-type view. Then the userlisting view is something like a parent view, which contains all fields of the profile-content-type view too. I already got a proof of concept working: profilelist The left fields belong to the usernode content type, the right fields name and age belong to the profile type. However for achieving this i had to extend the views query code a bit, I added the possibilty to define a prefix for the table aliases of the query. Now I'm going to generialize my code, build an UI and to create a patch for views.. :)