Aping Google Spreadsheets with Drupal Entity Forms and Droogle

Google Developer's logoOne recent small project which I worked on was the integration of Entity Forms with Google Spreadsheets. In porting the corporate site, we had the challenge of having to provide some existing Google forms on to the new Drupal platform.

Since Entity Forms are used, a nice integration was fairly assured with the Rules module. So far so good. The first challenge was the form creation which was a case of recreating the fields into the new entity form which was straight forward enough with some hidden fields to identify a fiew pieces of metadata for routing.

The next challenge was the Google form. These are essentially spreadsheets with a form interface. Fortunately there is a Drupal project called Droogle which integrates with Google Drive. Its main concern is listing the documents and collections and allowing users to upload a document having logged in and also has some Organic Groups integration. Since forms use spreadsheets, I had to extend Droogle a little.

Droogle itelf is a wrapper around Zend’s Gdata framework (no Zend framework needed just download and extract the library into the root of Droogle). The first thing that I had to do was to add the includes to take in the spreadsheet library and then extend the login function to allow swapping out each part of the API to have its own login and url to login to. (Yes I really ought to send it back as a patch.)

The next thing was to copy the original form so that the same data was asked for in the original form and then set up the relevant rules to route the forms. This relies entirely upon rules to send the correct response to the correct team.

What is nice is that having added in the spreadsheet code, the data can be imported into the relevant spreadsheet using the main Droogle settings. The spreadsheets API can only take column names if they have no punctuations and be lower case so these have to be prepared and then the passed into the Zend framework. You also need to make sure that the document name being passed in matches the documents one because you have to use the API to call all documents that the user has access to and then all sheets from that document.

One frustrating thing is that the PHP API has an issue calling the spreadsheets back. If the sheet has more than one tab or worksheet, then you need to be identify the correct worksheet or the data will not be entered.

Essentially the challenge was to create a push integration rather than pulling data from the documents. It would be great to have a couple of hours to spend working on the final bits to make this more generically useful for other people.

No Comments

Leave a Reply

Your email is never shared.Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.