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.
SquelletonCreate a new PHP file with the classic protection, and an empty div, for the HTML rendering.
IncludesThe following code if registering all classes of a thrid Cook component. Thanks to the loader, you will never need to include any other file. In this example, the module is based on com_ckfiles (download)
Load contentsReuse the models everywhere ! Here is the basic snipplet to load a list: A small difference to load a single item:
Show contents with JDomOnce 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.
A foreach loop is enumerating all items. When you deal with simple item object, just avoid the loop.
Download sample moduleIsn't it cool and easy ? |
|
I jumped and started to work on a demo component... but 2 days later this demo component became the real component. I just showed today the end result to my customer and he turned to me and said... "this is more than I expected"... All of this is because Cook did cut about 70% of my work and provided me more ways to improve the usability of the component. The end result was 17 tables all related between than to generate a full dashboard for the travel agents. Thanks for Cook developers for such great tool. This component would not be possible to be done at short time with all the features in it