Question

I have a need to build views in drupal of non-nodes, actually objects external to drupal. The api that I am calling against passes me back a stdClass object.

Anyone have ideas on how to get Views2 to display non-node objects?

Was it helpful?

Solution

My understanding of Views 2 is that it is meant to work with information stored in a database.

If you don't have access to the database against which the API was written, then consider writing the objects the API returns into a table. The easiest thing would probably be to create nodes from the objects. Then you could access them with Views 2.

This is similar to the approach taken by the Acitivty Stream module (http://drupal.org/project/activitystream). It creates nodes from the data returned by various APIs. Check out the module's code for examples of how to create the nodes:

http://cvs.drupal.org/viewvc.py/drupal/contributions/modules/activitystream/activitystream.module?view=markup

On the other hand, if you have access to the source database, you might consider exposing the tables of that database to Views directly. This is the approach taken in the latest Views 2 integration code included with CiviCRM v2.2.3, which you can review here:

http://svn.civicrm.org/civicrm/trunk/drupal/modules/views/

CiviCRM is a Drupal module that writes data to tables outside of the Drupal database -- not into nodes. The views integration code exposes most of those tables to Drupal.

Hope this helps.

-- Andrew B.

OTHER TIPS

According to the Views 3 roadmap, Views will eventually work with non-SQL data sources. In the meantime, some very preliminary work has been done in this area, using the Flikr API as a proof-of-concept.

Fixed in latest 6.x-1.x-dev branch. VBO now supports users and comments in addition to nodes. A special hook_object_info can be used to support any other type of object. Please try it and let me know!

Views is built for working with nodes + CCK exclusively. If you want to create views for custom pages, you'll need to code some additional module + theme pages.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top