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 ? |
|