| Making installation package for your Joomla component (Joomla! 1.0.x) |
|
This tutorial will explain you how to make an installation package for
you component for Joomla 1.0.x. version. In the upcoming Joomla 1.5.x
installation xml file is different and will be explained in new article.
Introduction
Although this article should be red after you you build your first component it would be good to read it before (and again later, of course). That is because we recommend you to build an empty component then install it on the working Joomla site and build (and debug) it from there. Before you begin...
Installation package is a compressed file (zip) containing information about files that are included in the package (frontend and backend), database preparation and uninstall information. Making your first installation package
First we will make installation package that will install empty component called 'Test'. You should create an empty folder com_test in which you will create two files: test.php and test.xml. Let's put the following content into test.php.
You will later add the real code here as this is the base file for all other files that you component will use. Now we will create a simple xml file that will explain Joomla how to install the component.
This is a very simplified version of xml installation file, but will do what we need. Component installation and testing
You should have a folder named com_test and files test.php and test.xml inside that folder. Now, create archive containing that folder (xp users can RMB click on the folder and click Send To -> Compressed (zipped) folder).
Now to test it open the frontend of your Joomla site and after url add "index.php" (if it isn't there already) and "?option=com_test" (for example http://www.joomla-example.com/index.php?option=com_test). Now you can go to folder "components/com_test" and open test.php file. You can now code anything you want and create other files and folders which you will link from test.php file. Administration part of component Now we will explain how to add administration part of component. Example above created only the frontend files which is uslually only half of component code.Administration files will be installed into "administrator/components/com_test" folder. Administration part of Joomla is separated from frontend, and everything that is related to your component configuration should be there.
Let's put the following lines above </mosinstall> tag.
The first two tags tells Joomla to create an administration menu items for your component. And the 'files' tag tells which files need to be copied to administrator/com_test folder. That's it. You if you install the component now you should be able to access it trough administrator interface. Other tags that can be used in the installation file There are a few other tags that can be used to deploy your component. To specify which image files your component needs you can use '<image>' tag, which contain '<file>' tags for each image.
You can use the '<image>' tag in frontend and administrator part of installation file. To execute a php script after successful installation you can use '<installfile>' tag.
Also, after uninstalling the component you can use '<uninstallfile>' tag.
These tags can be very useful if you want to give some information to user after install/uninstall, or if your component needs to perform some operations before first usage or after uninstall.
Database preparation If your component uses database you will need to add SQL code to your install file so that Joomla can execute it in the installation process. This can be easily done if you have functional component on your development Joomla site. All you need to do is to empty data from your tables (leave the data that needs to be there so that you component can be functional), and export the database using a tool you use for database administration (Navicat, phpMyAdmin...) Now you need to add the exported code line by line (not actually the text line, but the sql line which ends with delimiter ';') like this:
Every sql line is contained in the '<query>' tag. You can execute whatever you need, even modify existing Joomla tables (not recommended trough, as it can give your component bad reputation if not done very carefully). Summary Making installation script becomes more and more complex as your component grows. Also the maintance of your installation is a hard work as you will change the code and files from version to version. It would be a good thing to have your own organization schema that will help you track changes and implement them in the install.xml file. |
||||||||