Using Local Storage in a CMS (Become an expert)

So far, we've looked at using Local Storage in our websites. This assumes that they have been built from scratch over a period of time. However, we cannot afford to ignore CMS systems, particularly popular ones such as WordPress. The great thing is that a plugin for WordPress has been developed to take advantage of Local Storage. We're going to take a look at this plugin as part of this recipe.

Getting ready

For this task, you will need access to a working installation of WordPress, either remotely or using a local web server such as WAMP Server. I will assume you are using an instance of the latter for the purposes of this recipe (currently at version 3.5 at the time of writing this book). You will also need a copy of the open source Local Storage Backup plugin, which is at version 0.92 (at the time of writing this book), and is available to download from http://wordpress.org/extend/plugins/local-storage-back-up/.

Note

I would strongly recommend using Firefox for the purposes of the test at the end of this recipe. It handles the offline connection more gracefully than IE!

How to do it...

Perform the following steps, for using Local Storage in a CMS:

  1. Browse to your Admin area in WordPress, and then install the plugin in the normal way. If you are unfamiliar with this process, visit the WordPress Codex at http://codex.wordpress.org/Managing_Plugins. There you will find details on how to install plugins.
  2. To test that it is running, browse to Posts, then Add New, and write a post as normal. Make sure you include a title as well! Before publishing it, set the browser into offline mode and click on Publish. Instead of showing a 404 error, WordPress will show the following result, in the bottom-right corner of the post window:
    How to do it...
  3. This confirms the plugin is working. The message will then change as shown in the following screenshot:
    How to do it...
  4. Switch your browser back to online mode and click on All Posts to force a refresh. Your browser will show a message, confirming that posts still need to be published:
    How to do it...

How it works...

This is one of those plugins for WordPress that does a simple job well. It sets WordPress to divert any requests for publishing posts to LocalStorage, if it determines that you are working offline as a result of a dropped connection. As soon as your Internet access has resumed, it will recognize that there are posts that need to be published, and prompt you to complete this process.

There's more...

It should be noted that this plugin isn't designed to handle comments in a similar fashion. If you want to include this facility, take a look at another plugin called WP Local Storage, which is available at http://wordpress.org/extend/plugins/wp-local-storage/.

We're almost at the end of our journey through Local Storage. Before we finish, there is one more area we are going to look at, which relates to forms. Ask yourselves this question, "How many times have you visited a site as a registered user, only to find that it still thinks you are a new user?" Sounds familiar? We'll see how to avoid this, as part of the next recipe.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset