Actions

J2.5

Developing a MVC Component/Developing a Basic Component

From Joomla! Documentation

< J2.5:Developing a MVC Component
Revision as of 13:12, 2 November 2009 by Cdemko (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Documentation all together tranparent small.png
Under Construction

This article or section is in the process of an expansion or major restructuring. You are welcome to assist in its construction by editing it as well. If this article or section has not been edited in several days, please remove this template.
This article was last edited by Cdemko (talk| contribs) 4 years ago. (Purge)

Contents

The first basic component

We are going to create a 'Hello World! component.

Public display

With your favorite files manager and editor, create a file components/com_helloworld/helloworld.php containing

Hello world

You can test this basic component by putting index.php?option=com_helloworld in your browser address (don't forget to prefix this address by your Joomla!1.6 installation path).

Administrator management

With your favorite files manager and editor, create a file administrator/components/com_helloworld/helloworld.php containing

Hello world administration

You can test this basic component by putting administrator/index.php?option=com_helloworld in your browser address.

Packaging an installation zip file

If you have used Joomla before reading this tutorial, you have noticed that extensions are installed using a compressed file containing all the things which are needed for installing them and uninstalling them.

Delete the components/com_helloworld and administrator/components/com_helloworld directories of your Joomla!1.6 installation.

With your favorite files manager, create a directory (outside of your Joomla!1.6 installation) containing

Create a compressed file of this directory or directly download the archive and install it using the extension manager of Joomla!1.6. You can test this basic component by putting index.php?option=com_helloworld or administrator/index.php?option=com_helloworld in your browser address. You can also noticed that the Hello World! component is visible in the administrator site of your Joomla!1.6 installation under the menu Components.

helloworld.xml

<?xml version="1.0" encoding="utf-8"?>
<extension type="component" version="1.6.0" method="upgrade">
        <name>Hello World!</name>
        <!-- The following elements are optional and free of formatting constraints -->
        <creationDate>November 2009</creationDate>
        <author>John Doe</author>
        <authorEmail>john.doe@example.org</authorEmail>
        <authorUrl>http://www.example.org</authorUrl>
        <copyright>Copyright Info</copyright>
        <license>License Info</license>
        <!--  The version string is recorded in the components table -->
        <version>0.0.1</version>
        <!-- The description is optional and defaults to the name -->
        <description>Description of the Hello World component ...</description>
 
        <!-- Site Main File Copy Section -->
        <!-- Note the folder attribute: This attribute describes the folder
                to copy FROM in the package to install therefore files copied
                in this section are copied from /admin/ in the package -->
        <files folder="site">
                <filename>helloworld.php</filename>
                <filename>index.html</filename>
        </files>
 
        <administration>
                <!-- Administration Menu Section -->
                <menu>Hello World!</menu>
                <!-- Administration Main File Copy Section -->
                <!-- Note the folder attribute: This attribute describes the folder
                        to copy FROM in the package to install therefore files copied
                        in this section are copied from /admin/ in the package -->
                <files folder="admin">
                        <!-- Site Main File Copy Section -->
                        <filename>helloworld.php</filename>
                        <filename>index.html</filename>
                </files>                
        </administration>
</extension>

site/helloworld.php

Hello World

site/index.html

<html><body bgcolor="#FFFFFF"></body></html>

admin/helloworld.php

Hello World administration

admin/index.html

<html><body bgcolor="#FFFFFF"></body></html>

Contributors