1

The title says it all.

I'd like to create a view and provide rows for that view from a custom module where I've prepared the data for it.

The data is prepared when a page is visited and a callback function has run, the data is not stored in the database.

Is that possible somehow?

Thank you!

9
  • 1
    I'm sure someone can give you a proper detailed answer but until then check out hook_views_data() - api.drupal.org/api/views/views.api.php/function/hook_views_data/…
    – rooby
    Mar 21 '14 at 9:29
  • 1
    Oh in that case, if the data isn't actually stored anywhere views cannot use it.
    – rooby
    Mar 21 '14 at 9:39
  • 1
    @BálintDeáki The data must be somehwere, otherwise it doesn't exist. You say you prepare it in a page callback - where does the data that you use to prepare that come from in the first place? That's the datasource you need to expose to views
    – Clive
    Mar 21 '14 at 9:39
  • 1
    Anything's possible :) Views datasource exists for exactly that, but it's in dev so your mileage may vary
    – Clive
    Mar 21 '14 at 9:44
  • 1
    @BálintDeáki My mistake, I don't think there is a module for that then. It's theoretically possible (anything is), but the amount of work you'll have to do to convert Views from using DB to external API might make you think twice about it (you'll need to write pagers, filter handlers, aggregators, relationship handlers, the works). The quickest solution would be to cache your API data in a local DB table so views can get easy access to it
    – Clive
    Mar 21 '14 at 9:56
2

I know link-only answers are generally frowned upon, but this series of blog posts are unlikely to ever go anywhere and are WELL worth a read:

Building Views Query Plugins: Part 1 - Mapping web service data to the Views model

Building Views Query Plugins: Part 2 - Writing and testing the plugin itself

Building Views Query Plugins: Part 3 - Exposing options and configuration

Building Views Query Plugins: Part 4 - Building custom pager plugins

Note: In the unlikely event that someone gets here and the links are dead, please comment and let me know so I can address it :-)

1
  • Whoa! That's probably what I need, it'll be quite the challenge to get through this. Thank you! Mar 21 '14 at 10:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.