Using One-Click Update in Your Extensions
Do users encounter bugs in your extension because they're running an outdated version? You can make it super easy for users to keep up with your latest release by implementing the Joomla "one-click update" feature in your extensions. Then, each time you publish a new version, users are notified automatically that an update exists when they log into the back end of their Joomla websites. What's more, the user can implement the update simply by clicking the update icon in the Extensions: Update Manager screen.
Perhaps you're thinking, "Wow, that sounds cool, but it's probably hard to set up." Actually, implementing one-click update is pretty easy.
Here's an important point to understand. If you have an existing extension, you need to get ready for one-click update in one version, and then your users can use it for all future updates. Let's say your current version is 1.2.3. To enable one-click update, you need to release version 1.2.4 with some changes to the extension's XML installation file and a new SQL file. Once users have version 1.2.4 installed, they can use one-click updates for versions 1.2.5. and later.
Let's look at the changes in more detail. Your extension has an installation XML file that tells Joomla how to install and uninstall the extension. To enable one-click update, you need to add two elements to this file (as child elements of the extension element):
- update element. This tells the installer where to find database update scripts that are run on updates. For example, this code would be for the MySQL database:
<update> <!-- Runs on update; New in 2.5 --> <schemas> <schemapath type="mysql">sql/updates/mysql</schemapath> </schemas> </update>
<updateservers> <server type="extension" priority="1" name="MyExtension" >http://myupdatewebsite.com/updateserver/myextension-update.xml<;/server> </updateservers>
In addition, you need to create a SQL script file called admin/sql/mysql/1.2.4.sql. This file could be empty, or it could have a comment like this:
# Empty SQL file to set the version number in #__schemas table (for future updates)
That's all you need to do. Put this into your 1.2.4 version (in this example), and your users will be ready to enjoy the simplicity of one-click updates.
What do you need to do when you release version 1.2.5? That's also very easy. First, you need to include an updated SQL script, called admin/sql/mysql/1.2.5.sql in this example. Again, if you don't have any SQL changes in this update, the script can be empty or just include a comment.
The other required step is to create the update XML file (the one you named in your updateservers element earlier). Here's an example of that file:
<?xml version="1.0" ?> <updates> <update> <name>MyExtension</name> <description>My very cool extension</description> <element>com_myextension</element> <type>component</type> <version>1.2.5</version> <!-- This will be the version after the update. --> <infourl title="My Website">http://mywebsite.com</infourl> <downloads> <!-- Careful: No spaces or new lines are allowed in downloadurl. --> <downloadurl type="full" format="zip" >http://mywebsite.com/updateserver/com_myextension_1.2.5.zip</downloadurl> </downloads> <maintainer>Mark Dexter</maintainer> <maintainerurl>http://mywebsite.com<;/maintainerurl> <!-- This is the version of Joomla that this update works in. --> <targetplatform name="joomla" version="2.5" /> </update> </updates>
Make sure that you have a copy of the installation archive file (in this example, com_myextension_1.2.5.zip) at the URL in the downloadurl element.
That's all you need to do. Now, every time a user logs into the back end of the Joomla site, the system will check to see if a new version is available. If so, it will show in the Control Panel, and the user can simply click it to update to your extension's latest version.