Reading the JED meeting minutes, I discovered that there will be a new requirement as of 10th January 2017 that all extensions listed on the JED must use the Joomla Updater. While I support the idea, it struck me that there just isn't any documentation targeted to commercial extension developers. There is some documentation on Deploying an Update Server, and I wrote about Setting up an update server in Chapter 9 of Learning Joomla 3 Extension Development, however this only helps those that are wanting to give away their extension for free.
So the purpose of this article is to explain to commercial extension developers how they can leverage the Joomla Updater in their components, but still limit updates only to customers who have a current subscription.
Since writing this, @
My initial assumption is that you already have Akeeba Release Systems installed on your site and are using this to distribute your extensions. I’m also assuming that you are using Akeeba Subscriptions to sell your extension, and that customers are issued with an Akeeba download ID. If there is enough interest, I may write about setting these up, but for now I'll assume that you are capable of reading Nicholas' documentation and figuring out that bit yourself.
Throughout this example, I'm going to use a ficticious component called "Your Component (com_yourcomponent)", so when using this code yourself don't forget to replace COM_YOURCOMPONENT, com_yourcomponent and Your Component with the name of your component.
1. The first step is to add a component option to store the customer’s download ID. Add a field to store the download ID in your config.xml file
<field name="downloadid" type="text" default="" size="30"
description ="COM_YOURCOMPONENT_FIELD_DOWNLOADID_DESC" />
2. Next, you need to add the language strings for these options.
COM_YOURCOMPONENT_FIELD_DOWNLOADID_DESC="Enter your Download ID to enable Updates"
3. Add an update server reference in your installation XML file
Note, the id you select at the end of this url will be determined by the update stream you create in Akeeba Release Systems.
Note you can add this at the bottom of your installation XML file, just before the closing </extension> tag.
<server type="extension" priority="1"
4. In the controller for your default view, add the following:
Note, this should probably go in your model instead of the controller as we are dealing with a database call, but for now lets just be lazy. Essentially what we want to do is update the jos_update_sites entry for our extension and include the download id.
public function __construct($config = array())
$component = JComponentHelper::getComponent('com_yourcomponent');
$dlid = $component->params->get('downloadid', '');
if (empty($dlid)) return;
$extra_query = "'dlid=$dlid'";
$db = JFactory::getDbo();
$query = $db->getQuery(true)
->set('extra_query = '.$extra_query)
->where('name = "Your Component"');
Note the name above should exactly match the name in the updates server section of your installation XML file.
That’s all you need to do in the component, the rest of the work is on your site where you have Akeeba Release Systems installed.
In the item record for this release in Akeeba Release Systems, make sure you select the appropriate update stream, and which versions of Joomla (Environments) this release is compatible with.
The Joomla updater should now see your extension has a new version available.
If a user tries to update without a valid download id, they will see an error.
Assuming user has correct download id entered, and has a valid subscription, then they will be able to update the component.