tags:

views:

1384

answers:

4

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?

A: 

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.

Seb
Untrue. Views 2 can make views of mostly anything that can be stored in a relational database, all you have to do is describe it via the Views API.
mikl
A: 

you have to expose custom data to views like described here:

http://www.darrenmothersele.com/drupal-blog/drupal-views2-handlers http://views-help.doc.logrus.com/help/views/api-tables

gpilotino
Thanks. but what I am not seeing is a way to have Views display something that does not come from a table. Any ideas on that?
Brian G
+4  A: 

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.

andrew b
+1  A: 

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.

jhedstrom

related questions