How to create a module ?

This chapter introduce how to create a modules that shows contents from Cook generated components.

The XML manifest file is explained by Joomla! documentation, and a sample is furnished in download, so the purpose of this article is to explain the PHP/HTML part only.


Create a new PHP file with the classic protection, and an empty div, for the HTML rendering.


The following code if registering all classes of a thrid Cook component. Thanks to the loader, you will never need to include any other file.
You can call infinite component loaders in the same module.

In this example, the module is based on com_ckfiles (download)

Load contents

Reuse the models everywhere !
They handle all securities checks and complexity.

Here is the basic snipplet to load a list:

A small difference to load a single item:

Show contents with JDom

Once the datas are loaded in object, or array for list, the most easy way to render them is to use JDom.

JDom needs to know the component to deal with. In case of a module, the option parameter in the url can refer to another component.
This is required when JDom needs to interract with component helper. In our example, for indirect file access to build the url.

And now, the HTML structure, with a single JDom call:

A foreach loop is enumerating all items. When you deal with simple item object, just avoid the loop.

Download sample module

Isn't it cool and easy ?
Anyway, if you are lazy to reproduce the steps, you can download this tutorial module here.

Get Started