Documentation Menu

1.5 Template Project

The Joomla! Documentation Working Group is running a project to develop detailed reference and tutorial material on Joomla! 1.5 templates.  There is a project page on the documentation wiki where you can see the work in progress and help us by contributing your knowledge.

Who's Online

We have 8 guests online

Help Site License

The Joomla! Help Site content is copyright © 2005 - 2008 by the individual contributors and can be used in accordance with the Creative Commons License, Attribution NonCommercial ShareAlike 2.5. Some parts of this website may be subject to other licenses.
Home arrow Manual arrow 7. Packaging Custom Work arrow Component Setup File

PDF Print E-mail

Packaging Custom Work :: The Component Setup File 

A Component differs from a Module in that it's more complex and can have extra features to maintain data.

The XML for a Component installation could look like this:

<?xml version="1.0" ?>
<mosinstall type="component" version="1.0">
  <name>My Joomla component</name>
  <creationDate>15/09/2005</creationDate>
  <author>Joomla</author>
  <copyright>(C) 2005 Open Source Matters. All rights reserved.</copyright>
  <license>http://www.gnu.org/copyleft/gpl.html GNU/GPL</license>
  <authorEmail>admin@joomla.org</authorEmail>
  <authorUrl>help.joomla.org</authorUrl>
  <version>1.1</version>
  <description>This is a brief description of the component</description>
  <files>
    <filename>mycomponent.php</filename>
    <filename>mycomponent.html.php</filename>
    <filename>images/approve.png</filename>
  </files>
  <install>
    <queries>
      <query id="1"># create a table</query>
      <query id="2"># populate new table</query>
    </queries>
  </install>
  <uninstall>
    <queries>
      <query id="1"># delete the table</query>
    </queries>
  </uninstall>
  <installfile>install.mycomponent.php</installfile>
  <uninstallfile>uninstall.mycomponent.php</uninstallfile>
  <administration>
    <menu>My component</menu>
      <submenu>
        <menu act="sub1">Sub menu 1</menu>
        <menu act="sub2">Sub menu 2</menu>
      </submenu>
    <files>
      <filename>admin.mycomponent.php</filename>
      <filename>admin.mycomponent.html.php</filename>
      <filename>toolbar.mycomponent.php</filename>
      <filename>toolbar.mycomponent.html.php</filename>
    </files>
    <images>
      <filename>administrator/images/approve.png</filename>
      </images>
  </administration>
</mosinstall>

As you can see it has more sections; the sections that differ from the common ones are described below.

There is no limit to the number of <filename> entries and they may refer to sub-directories which will be created by the installer.

As the nature of a Component gets more complex you can use the <install> section to specify creation of tables and the insertion of default data. In the <install> section you can have <queries>. <queries> is where you can have all the SQL statements that your Component requires e.g. creation of new tables and adding data to these new tables. There is no limit to the number of <query> sections. Each query must have an id field so that it can be uniquely identified.

If you have HTML in any of your queries you need to add <![CDATA[ in front and ]]> at the end. For example:

<query><![CDATA[ INSERT INTO #__mytable VALUES
   (1, '<P>HTML tags in queries</P><br><a href="http://www.mysite.com">My Site</a>');]]>
</query>

The <installfile> element is used to specify an additional file where you can add code that will be called at the end of the installation. The file MUST have a com_install() function in order to work. In the com_install() function you can have additional functionality to make the Component work. The com_install() function must return a string with a status, which will be displayed to the user at the end of the installation.

The <uninstallfile> element is used to specify an additional file where you can add code that will be called at the end of the uninstallation. The file MUST have a com_uninstall() function in order to work. In the com_uninstall() function you can have additional functionality to do any cleaning up. The com_uninstall() function must return a string with a status, which wil be displayed to the user at the end of the uninstall.

The <administrator> section is used to add functionality to the Administrator part of Joomla. The <menu> section is used to specify the name of the menu for maintaining the Component, it will appear under the Components menu. If your Component needs it, you can have sub menus; use the <submenu> section to add sub menus. The <menu> section of a sub menu has an additional "act" attribute, which is passed to your component. A sub menu must have either a "act", "task" or "link" attribute specified. Sub menu entries with the "link" attribute set will link to the specified URL. The "act" and "task" values can be retrieved using the mosGetParam function.

The <administrator> section also has <files> and <images> elements. These work the same way as described before, with the difference that files are copied to /administrator/components/[component_name]/ and images to /administrator/components/[component_name]/images/.


Please report any errors on this page to the Developer Documentation Forum.
Last Updated ( Friday, 08 September 2006 )
 
< Prev   Next >