Switch between Drupal and and your code editor! Create file backups! It's Save-to-File!

Ever wish that Drupal had a front-end code editor? Frustrated with using the space bar to indent code in textareas? Wish you could back up your node code to a hard file? Then Save-to-File might be the solution for you!

Save-to-File adds a link under a textarea to "Save to file". When clicked, some handy javascript moves the entire content of the textarea to a file, and replaces the textarea content with a short function that will grab the content from a file the next time the content is loaded.

Common Workflows:

Switching between Drupal and Your Favorite Editor

  1. You start creating your code in a node content's textarea and realize that you'd really appreciate some syntax highlighting and automatic tag completion.
  2. You click "Save to file" to save the content you've already created to a file via ajax.
  3. You save the node and view the page.
  4. You open the new file up in your code editor. Now you can work with the content as a static file. Changes will be reflected in the browser because it's drawing from the file contents.
  5. Later on, when you're updating your site, you want to edit the content using Drupal instead of your editor. No problem! You just click a 'Load from file' link and it loads the content of the file back into the textarea via ajax (no extra page-loads). When you submit the form, it will automatically remove the old file (however, you can turn this off if you want to keep backups).

Saving File-based backups of complicated content

  1. You're feeling nervous about not having a hard copy of some code you've created somewhere in Drupal's configuration, or in a node. You could make a backup of the database, but you're looking for something simpler.
  2. You mosey over to Save-to-File's settings page, check the "Do not delete files" option and save the settings.
  3. Back to the page where your content is, you click on "Save to file". Now you have a hard copy of that code!
  4. Finally, you click on the "Load from file" link to load the content back in. Sweet.

Save-to-File Features

  • Slick ajax-based saving and loading of content to and from hard files
  • Can be used on any textareas on a site. You can specify which pages to use the tool on. It's not just for node forms!
  • Save-to-File will keep the file directory clean of unused content files, but if you want to save backups, there's an option to do just that.

Save-to-File README.txt

Save To File module:
Author - Chris Shattuck (www.impliedbydesign.com)
License - GPL

The Save To File module allows a user to save the content of node textbox to a file, for
easier editing or for backing up complicated pages.

To install:
- Download the module
- Add the files to your module directory
- Enable the module

To use:
- To save the content of a textarea to a file, click the "Save to file" link at the bottom
of the textarea
- To load it back into the text area, click the "Load from file" link.

- When saving the text to a file, the content is replaced with a PHP function. This means
that in order to display the content, the textarea needs to be able to process PHP. For
a node form, this means enabling the PHP input filter. Other textareas vary in how they
process content.
- Save-to-File is enabled automatically for anything matching node/*. To enable it for other
textareas, you will need to change the Save-to-file settings at admin/settings/savetofile.
- You can save and load content on a page several times without saving the page itself.

Implied By Design Logo