"Services Field" module?

We encourage users to post events happening in the community to the community events group on https://www.drupal.org.
barobba's picture

Is there a module that caches "services" requests to node fields? For example:

$node->field_service_handler[0]['handler_url']
$node->field_service_handler[0]['handler_request']

This would be useful for service requests to take advantage of the various node-level modules, such as comments, views, etc. I have this working somewhat. The question now is "formatters".

This type of module might be unique because the choice of formatter is not easy to determine from the node type's "Display fields" menu.

The naive solution (which might be a good way to go) is to present the user with a long list of formatters for all possible services, and if a formatter/sevice_request combination is missing, then the field would simply return empty.

Before continuing too far on this module, I wanted to check if anyone knows of a module that already works in this manner.

As far as a method for picking "formatters", there are many techniques out there that are similar:

Fields
Embedded media fields
Services
Flickr
Views

Comments

I implemented on my own the

Sylvain Lecoy's picture

I implemented on my own the handling of fields.

And this is probably related to my issue #1133984, because the field implementation doesn't allows easy formatting, _view hooks only returns them-able arrays that you can't do anything with (mainly because of the HTML wrappers). Moreover, it adds unnecessary complexity.

I'm not sure if you were speaking about that ? Tell me if i'm wrong.

Sylvain, thank you for your response.

barobba's picture

Sylvain, thank you for your response.

Drupal can make service calls (as input) and format the result into HTML. Drupal can also become a service provider (as output). I was talking about the first part, when Drupal receives data from another service and formats the information.

Drupal's module hooks and theme engine are well-suited for making service calls, and formatting the results. This can occur in: nodes, blocks, templates, etc.

I was asking, do you think it would make sense for "service call hooks" to be placed in a field, instead of writing a custom module to handle a node's service requests? Or, do you know of a module that does this already? In my case, I would also want to cache the service request string.

If so, then I have a follow-up question. New node types are assigned fields, and the fields are assigned to formatters. If the return data from a service request is consistent across service requests, then picking the formatter is trival. If the return data might vary in structure (e.g calling multiple service providers), then...hmm...how could hat be handled?

Here are some possible solutions for the second question:

  1. Create a proxy service that would unify the results. Then make calls to the proxy service.
  2. Create one or more formatters that are intelligent enough to unify the results (or an additional page for setting any additional formatting options).
  3. Let the author choose, and customize the widget to display any additional options that will be used by the formatter.

Services

Group organizers

Group categories

Group notifications

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

Hot content this week