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.



Squelleton

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



Includes

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.

Just wanted to congratulate you on the J-Cook website / web development tool. In a couple of visits I've had a play around with Cook and have to say I think it is fantastic.  I've played with a number of component builders in the past and yours is certainly looking like the best so far. I'd also like to help you spread the word - I'm really surprised more people aren't excited about this tool. Good luck with the project.
Dean

Get Started