Views adaptation for non-nodes

Events happening in the community are now at Drupal community events on www.drupal.org.
raymondlee's picture

I'm attempting to adapt the views module for non-nodes. Is this something that should even be attempted? Has anyone tried this?

I started by commenting out calls to db_rewrite_sql and changing the _views_query->query() method. This is quite hacky.

Any leads would be helpful.

-Ray

Comments

This is both easy and hard

merlinofchaos's picture

This is both easy and hard at the same time.

The underlying query object is theoretically flexible enough to use whatever 'central' table type you give it. (It does rely on a particular table being central).

The data model on top of that, though, assumes node centricity, and you'll find a lot of the views relation data is not relevant. That data would need a serious overhaul to convincingly use other tables.

Could you elaborate?

robertdouglass's picture

How do you define the central table? What if I want to build a view that recreates the watchdog table, for example? This would require selecting only on one table with a possible filter and no joins. How close can I come now, and what would need to be done to make the views module all-purpose enough to support this well?

Well...

merlinofchaos's picture

The join info in the views data assumes that you'll ultimately be joining down to the node table. This was done in order to make the system basically understandable, by never presenting that data to the user on a UI level. Without having to think about how tables join together, one major piece of complexity was removed.

And the UI is still considered hellishly complex.

I don't have a good answer for how to actually do what you want to do, except to say that it re-introduces significant complexity.

Could alternate central tables be defined?

robertdouglass's picture

I think people could come to terms with a UI that made them choose a central table (defaulting to node). You would even be able to offer fields/filters/sorts based on whether they were children of the chosen central table, so that if I chose user as the central table, Node: Title would disappear and User: role would appear in the Fields.

As a programmer, the two things that I can see that will stop me from making Views the center of my entire universe are the ability to chose a central join table and the ability to extend the arrays that get built in the node_views_tables() and similar hooks.

Can you imagine Views going in these directions, and what would the roadmap look like?

First, a significant thank

logictude's picture

First, a significant thank you to the developers behind the Views module. The Views module has, by far, become my favorite module within the Drupal melting pot. I'd also like to add that we do not mean to step on any toes by re-broaching the subject of non-node centric tables.

And, maybe this has already been done. It's possible I missed this.

The problem: We wanted to use the Views module, in all its glory, to create a variety of views for a large amount of data. (The power and flexibility of the Views module is undeniable.)

The solution: Modify the Views module to handle a different central table. That, as merlinofchaos has pointed out, isn't a terribly complicated thing to do, it's the reliance on the node table by all the subsequent add-ons that will prove most challenging.

Anyway, I'm just rehashing. Here's what we did. We changed a few lines in each of the following: views.module, views_ui.inc, views_query.inc, and views_node.inc, I'd say maybe a dozen lines in all. Oh yeah, and we added one column to {view_view}. After making these minor changes we created a simple views_watchdog.inc add-on module that allowed us to create our own watchdog view.

I wanted to see if there was still any interest in this before I put together any more information (patch, etc.). Obviously there's some work that still needs to be done, as it's quite easy to create a malformed query. We're pretty new to the whole Views development world so we're taking some baby steps.

Thoughts?
-andrew

much needed

moshe weitzman's picture

many people are thirsting to slice and dice users and comments via Views. I encourage folks to explore with this.

Yay, this will be supported

wim leers's picture

Yay, this will be supported by Views 2 by default! See http://www.angrydonuts.com/views_2_high_level_design.

Views Developers

Group organizers

Group notifications

This group offers an RSS feed. Or subscribe to these personalized, sitewide feeds: