0

I've written a simple Joomla plugin that I've been using for a year.

I want to write an update for it. It would change what is in the .xml file and some code in the .php file.

How do I go about doing this? What is the best practice? Do I create a new version and simply re-install it and that would overwrite what is there?

2

I would update your source .xml and .php with your changes and make sure you have method=upgrade in the line like this example. and change your <version>to a higher number.

old

<extension version="3.9" type="plugin" group="content" >
<version>0.0.1</version>

new

<extension version="3.9" type="plugin" group="content" method="upgrade" >
<version>0.0.2</version>

Then when you install your new .zip it should overwrite the existing one.

  • So I would maintain an installed version and an upgrade versions of this Joomla plugin? – Edward_178118 Oct 21 at 6:04
  • I wouldn't think you would need to. You might take a copy of your local plugin files before you change them and put them in archive type folder so you have something to fall back on if needed, but the general approach is update your existing plugin code and increment the version= field before you install it. Your updated plugin .zip needs to have ALL the files required to run, not just the ones you have changed. – Irata Oct 21 at 7:37
  • 1
    The extension version has nothing to do with the version of the actual plugin. You need to change the value of the node, not attribute – Lodder Oct 21 at 15:30
  • @lodder. Thanks I have updated the answer to show the correct place to modify the version. – Irata Oct 21 at 22:04
1

If you add the attribute method="upgrade" to the tag extension, your plugin can be installed without uninstalling an earlier version. All existing files will be overwritten, but old files will not be deleted. So you do not need two versions - one for updating and one for new installation! (https://docs.joomla.org/J3.x:Creating_a_Plugin_for_Joomla)

If you create an update, then you should also consider setting up an update server: https://docs.joomla.org/Deploying_an_Update_Server

  • 1
    "All existing files will be overwritten, but old files will not be deleted" didn't make sense to me but the Joomla Doc in your link does say that. However I tested a plugin with update= and it will overwrite existing files and also remove a file if it does not exist in the newer plugin. My test involved renaming the index.html file to something else each time and only the incoming version remained. I did recreate appearance of the old files not being removed, but that was caused by my Windows/7-zip right click button 'Add to .zip' not removing the old file so it gets installed with the plugin. – Irata Oct 21 at 10:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.