Actions

J3.x

Difference between revisions of "Developing a MVC Component/Developing a Basic Component"

From Joomla! Documentation

< J3.x:Developing a MVC Component
(2 intermediate revisions by one user not shown)
Line 3: Line 3:
 
= Developing a Basic Component =
 
= Developing a Basic Component =
  
This page goes through the basic steps required to make the simplest possible component that will output ''Hello, world!'' to the [[Site (Application)|front-end]] of a Joomla!{{JVer|3.1}} website.
+
This page goes through the basic steps required to make the simplest possible component that will output ''Hello, world!'' to the [[Site (Application)|front-end]] of a Joomla! {{JVer|{{CurrentSTSVer|minor}}}} website.
  
 
== Main Output ==
 
== Main Output ==
Line 25: Line 25:
 
<extension type="component" version="3.1" method="upgrade">
 
<extension type="component" version="3.1" method="upgrade">
 
<name>Hello World!</name>
 
<name>Hello World!</name>
 +
        <administration > </administration>
 +
        <files>
 +
                <filename>helloworld.php</filename>
 +
        </files>
 
</extension>
 
</extension>
 
</source>
 
</source>

Revision as of 03:15, 3 June 2013


This is a multiple-article series of tutorials on how to develop a Model-View-Controller Component for Joomla! Version Joomla 3.x.

Begin with the Introduction, and navigate the articles in this series by using the navigation box to the right (the Articles in this series).

Developing a Basic Component

This page goes through the basic steps required to make the simplest possible component that will output Hello, world! to the front-end of a Joomla! Joomla 3.3 website.

Main Output

First set up the basic public output for this component. Create yoursite/components/com_helloworld/helloworld.php with the following contents:

<?php
 
echo 'Hello world';

Manifest file

Every extension needs a manifest file that specifies installation and configuration information for the extension. The manifest file is named componentname.xml. For a simple component we need only include a minimal number of the possible elements in this XML file.

Create helloworld.xml in the same directory as your helloworld.php above, with the following contents:

<?xml version="1.0" encoding="utf-8"?>
<extension type="component" version="3.1" method="upgrade">
        <name>Hello World!</name>
        <administration > </administration>
        <files>
                <filename>helloworld.php</filename>
        </files>
</extension>

Note that the name element is actually optional, but it makes for easier identification in the next step.

Installation

Next, we need to tell Joomla! to 'discover' this new component, so that it can be installed and used. This is done by going to the Extension Manager -> Discover and clicking 'Discover' in the toolbar. This will scan the components directory (amongst others), looking for components that have not yet been installed.

The new component should be listed in the resulting table, and to install it you just select it (with the checkbox) and click 'Install' in the toolbar.

Note: Don't worry about the message "Component Install: The XML file did not contain an administration element", as our component does not yet have any administration features. We'll add these later in the tutorial.

Hello, world!

You can now see the basic component in action, by navigating to http://localhost/joomla/index.php?option=com_helloworld (replacing localhost/joomla with your own installation location).