Upgrade Your Drupal Skills

We trained 1,000+ Drupal Developers over the last decade.

See Advanced Courses NAH, I know Enough

Quick idea for a Google Doc node with in-place viewing and editing

I've often wished document editing were more user-friendly in Drupal. So I came up with this very half-baked idea to embed the viewing and editing of a Google Doc in a node field. Following is a proof of concept. The code is embedded in this very field to selectively render the viewing or editing mode of the document (Note the Edit Google Doc link below):
<?php if(arg(0) == 'node' && arg(2) == 'gdoc') { // Editing ?>
Cancel Editing

<?php } else { // Viewing ?>
Edit Google Doc

<?php } ?>
Edit Google Doc To get the proper editing link, I used the one given to me by the document when I click "Share". To get the viewing link, I had to publish the document to the Web and used the link in that dialog.

This proof of concept could be turned into a module that packages this functionality as a new Field API type, responding to viewing or editing modes by embedding the corresponding URL. For tighter integration with Drupal, several ideas some to mind:

  • Create a new document when creating the node.
  • Using Google API to retrieve document text for indexing.
  • Injecting a custom CSS into the Google Doc iframe to style it with the Drupal theme.
That's it! Enjoy.
Author: 
Original Post: 

About Drupal Sun

Drupal Sun is an Evolving Web project. It allows you to:

  • Do full-text search on all the articles in Drupal Planet (thanks to Apache Solr)
  • Facet based on tags, author, or feed
  • Flip through articles quickly (with j/k or arrow keys) to find what you're interested in
  • View the entire article text inline, or in the context of the site where it was created

See the blog post at Evolving Web

Evolving Web