NodeOne talks Drupal: Views 3 + YQL + arguments (and Panels!)

This is a follow-up for the last screencast about YQL and Views 3. Some 48 hours ago YQL Views Query Backend got a new dev version that includes argument handling. For many people that might not mean much. For me it means support for Panels. This screencast shows how to integrate YQL views in Panels to route around information to and from external databases. It also disusses some problems that have to be solved before YQL + Panels can be used fully together.

This screencast can also be downloaded at archive.org.

  • Views does: fetch data, manipulate data, display data.
  • YQL does: get data from the 1000 tables at datatables.org and make it available to Views.
  • Panels does: load and manipulate data under the name contexts and make it available, for example as view arguments. (And it does some other fancy drag'n'drop stuff, I've heard…)

Combine these three and you can do cool stuff. Like what?

  • Fetch profile data from the logged in user and display her Twitter friends or Facebook notifications.
  • Read a geographical location from a node, let YQL get longitude and lattitude, and let Views display it on a map with the help of any suitable module.
  • Make a Google search for web pages linking to the active page and display their titles in a views list.
  • Get best matches from Flickr when you query for all the tags in an article.

In this screencast another example is displayed – how to list Twitter posts that contain all (or any) of the tags listed with an article.

Sure, it has been done before. There are Drupal modules that does (almost) this out of the box. But this is one example of what you can do – and do with standard Drupal tools as long as YQL works well. And, at least for me, multi-purpose modules beat single-purpose modules any day.

Below are some more comments about what I think is missing and prevents this kind of features to really take off. If you're not interested in deep dives into context handling within Panels/CTools, jump ahead to the comments and write a line about what you would like to do with these modules!


So, what's still missing? Well, there are some features in the YQL module that probably should be included – like handling missing arguments in a more flexible way, or (I would wish) a better way of knowing what fields are available and what the base object really means.

But I am more interested in the way YQL, Views and Panels can work together and send data between one another. A problem that hinders some really cool stuff is that it isn't possible to send off sensible arguments from Panels to Views – you can't for example use CCK fields as arguments.

In CTools there is a context object called string, that is (as far as I know) only used for fetching data from the URL and making comparisons for visibility rules or selection rules for panel variants. I would like to be able to add string contexts just as I can add node, user and taxonomy term contexts. And I would like to be able to use tokens to define these strings, so I can – for example – change [field_twittername] to @[field_twittername] when I do some lookups against Twitter.

(It would be awesome if there was a tool for handling multiple-value fields, by having a manually defined concatenator and then glue all values to a single string.)

Something that I realize is quite difficult to get to work, but would so awesome, is if it would work to use YQL View results as contexts in Panels, and then load contexts from the results in the view – like you can send in a view with nodes and then use result number one to load a node object as context. The problem with this is that the YQL results don't have a base object that makes sense to Panels or CTools. They are not nodes, users, comments, terms or anything else that Drupal is used to handle. So what could it be? My thougts is that it could be loaded as a string context, or perhaps an array of strings. A colleage of mine suggested defining a general object, which might be a good idea (but I can't really tell).

Anyway. These modules are really cool in combination. It's inspiring working with them, and I look forward to keep discovering what they can do.

DISCLAIMER: Every Wednesday (or so) someone at NodeOne makes an unprestigious presentation about something related to Drupal. The presentation is mainly for internal use, but we have decided to share recordings of the presentations to anyone interested. They are shared as-is – there screencast is uncut, sometimes interrupted, can contain noises and bad sound capture. They can also contain useful information about Drupal.

Are you too fascinated by YQL + Drupal? Consider voting for my View 3 + YQL session at DrupalCon Chicago!.