I have a custom component for Joomla. I understand how to install some data using the sql file of component. Now I want to add some data to the database tables in a separate package. I can't find any documentation on this and I'm not sure what's the best way to do it.

Would I need a separate plugin to install the data? Since it's only adding data to the database, I don't want to polute the plugin list with this. Because the data is added to the existing component tables, it's not something that should be managed or uninstalled after installation.

Is there a package type that allows this?

1 Answer 1


I think you are aware, that you can create hooks on install process.

E.g. https://docs.joomla.org/J2.5:Managing_Component_Updates_(Script.php) https://docs.joomla.org/J3.x:Creating_a_simple_module/Adding_an_install-uninstall-update_script_file

Here is my approach, where I after install publish plugin as an example https://github.com/gruz/NotificationAry/blob/master/scriptfile.php

You can use postflight hook in your demo data extension to uninstall itself programmatically.

I did such a thing in the past but I don't have an example.

Or you can, if you have a plugin you develop which assumed to be installed before the demo data extension install, in that plugin check what is installed and the uninstall that extension. There is a bunch of hooks for it. https://docs.joomla.org/Plugin/Events#Extensions

And, as an option, you can add an upload button to your component to upload test data and handle it in your component - get uploaded file, extract if needed, run queries from the file. Then no need with install-uninstall programmatically. I'd use such an apporach.

But self-uninstall seems interesting to be implemented just for fun :-)


A point to start looking how to self-uninstall. https://stackoverflow.com/questions/44155005/joomla-3-xx-how-to-uninstall-and-install-component-or-package-programmatically#44203211

Or, dirty way, run query to remove corresponding record from #__extensions and unlink files. But I'd rather examine Joomla API and find a legal way to programmatically uninstall an extension.

P.S.S. https://docs.joomla.org/Extension_Installer/Installer_Hooks

The preflight hook ... At this point you could conceivably prevent the installation by calling the abort mechanism from the parent or prepare anything ahead of the file copy and database changes occurring. ...

As an option In preflight hook execute you demo data install code but return false to pervent your extension instllation. Add a message for a user "Demo data installed, ignore joomla error message on failed installation". :-)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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