I have an app that has a front end in tons of custom AJAX and fancy JS controls.

These controls all pull from URL which return JSON in a specific format.

I would like to remove all the selection code from the existing system and integrate with drupal:

  1. Can views be linked to tables which are not directly managed by Drupal?
  2. Can Views have their output overridden to support JSON instead of HTML?

I have googled and found a few projects but none seem to be very active -- I am using D7 maybe D8 for this project :)

Any pointers, hook suggestions, etc?


After using hook_views_data() to declare your custom tables/fields, use a custom Views handler to override or reformat the output.



Can views be linked to tables which are not directly managed by Drupal?

This is done by the data module - here is a heads up.

Can Views have their output overridden to support JSON instead of HTML?

Install the views datasource project, then enable the views_json module. This outputs the view fields as JSON. You set the output format to JSON, configure it, and all fields are outputted as JSON:

Views Datasources JSON settings

Take care to uncheck views api mode if you simply want a JSON file.

Add a path to the new 'page'-type display, and you will see the JSON output.

For me it was somewhat limited, since I you can't change the field names (only hide them). Maybe you have a solution?


Module Forena can be used to query (not update) any MySQL database table. And Forena can be used as a views style. So the combination of these 2 Forena features should perfectly address the 1st part of the question.

For more details about Forena, 2 types of documentation are available:

  • Community documentation.
  • Documentation that comes with Forena, which you can access right after install and enable of the module. Checkout the demo site for an online example of the current:

    • Forena documentation - use the link 'Reporting documentation' or visit relative link /reports/help.
    • Forena samples - use the link 'Reporting samples' or visit relative link /reports/samples (these samples are fully functional, so make sure to experiment a bit with it, such as the drill downs available on the SVG Graph sample).

The newest 7.x-4.x version also includes an amazing (I think) UI for either creating your reports (the WYSIWYG report editor) and/or for creating your SQL queries (the Query Builder).

Here are some variations of the mysql database part in the question:

  1. Using a SQLite instead of MySQL database: the Forena samples actually get shipped including a (Tiny) SQLite database. Go check it out in the demo site: the data shown there are data contained in the sampledb, which is in SQLite format.
  2. Forena comes with a full suite of Supported database connections ... such as MS SQL, Oracle, Postgress or any PDO compliant variation.

Enough reasons for considering giving Forena a try? While doing so, use it's issue queue for any type of support/docu requests you may have.

Be aware: I'm a co-maintainer of Forena.

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.