Joseph L. LeBlanc
homeportfoliojoomlabiocontactblog
articles
guides
tutorials
all
forum
Subscribe in NewsGator Online

Learning Joomla! for the first time? Buy the Joomla! 1.5 Essential training CD-ROM or watch it on Lynda.com.

 

Bare Minimum Joomla Component PDF Print E-mail
By popular demand, here is the Bare Minimum component. This component has no parameters, database queries, external classes, or superfluous installation files.

You can also remove the baremin.php and admin.baremin.php files, as well as the references in the XML file, and the component will still install. However, this will not be very useful, unless you remove one or the other to create a frontend or backend only component.

Mambo always loads [componentname].php for the frontend and admin.[componentname].php for the backend. Other files can be included from these when a separation of logic is necessary. To port an existing PHP application to Mambo, you may wish to use this component and include the files for the application from baremin.php.


A downloadable copy of the component can be obtained here. The code from each file is outlined below.

admin.baremin.php

<?php
defined('_VALID_MOS') or die('Direct Access to this location is not allowed.');

?>

The check to ensure the predefinition _VALID_MOS is necessary to make sure that visitors do not load these files directly. Otherwise, security breaches are possible as the visitor would not have to go through the administrator section login.


baremin.php

<?
defined( '_VALID_MOS' ) or die( 'Direct Access to this location is not allowed.' );

?>

The frontend code is identical to the backend. Although the security risk is not as great, it would still be possible for someone to wrap this file in malicious code from a remote server, so the constant check is necessary.

baremin.xml

<?xml version="1.0" ?>

This tag identifies that this is an XML version 1.0 document, so that the parser knows what to expect.

<mosinstall type="component">

The outer <mosinstall> object defines the installation type as "component", which will stop the process if someone tries to install the component through the module, mambot, or template installers.

<name>BareMin</name>

This name of the component should match the name found throughout the XML and PHP filenames. Do not use spaces or characters that are not legal for filenames.

<creationDate>4/27/2005</creationDate>
<author>Joseph LeBlanc</author>
<copyright>This component in released under the GNU/GPL License</copyright>
<authorEmail>contact@jlleblanc.com</authorEmail>
<authorUrl>www.jlleblanc.com</authorUrl>
<version>1.0</version>

Although these properties are not absolutely necessary, they do help identify your component.

<files>
<filename>baremin.php</filename>
</files>

The <files> tags enclose a list of files for the frontend. If you want to use subdirectories of the com_baremin directory, add the directory name you wish to use, followed by a slash, followed by the name of the file to put there.

<administration>
    <menu>Bare Minimum</menu>
<files>
    <filename>admin.baremin.php</filename>
</files>
</administration>

The <administration> tags enclose the items to add to the "Components" menu and the files to use for the backend. The <menu> tag defines the title to use for the component throughout the backend. You are able to use spaces and special characters here, where you were not allowed with the <name> tag above.

</mosinstall>

This tag closes the installation object.