The focus of this course, is to Create a Custom Joomla 2.5 Module step by step guides. I hope You have already learned Joomla Installation , Create a Joomla Hello world Components from this blogs. Let we start our new Joomla CMS Custom Module Course Here,
There is a defined folder structure for Joomla extension. Create the files and folders as per the below using your code editor.
Create the main folder which will be called "mod_siteusers". Then create the files/folders below.
Important: As per the Joomla extension, the mod_siteusers folder needs to be in your Joomla sites "Modules" folder BUT do not put it there yet because we need to create everything first then pack it in a zip file to install via Joomla admin area.
below the file strcture need to be create for out Joomla Module (mod_siteusers)
-mod_siteusers.xml
-mod_siteusers.php
-helper.php
-index.html
--tmpl (folder)
--tmpl/default.php
--tmpl/ordered_list.php
--tmpl/index.html
Okay, lets begin with carefully
mod_siteusers.xml
This file holds all of the modules metadata, information and parameters. The file structure must be exact.
name="moduleclass_sfx"
type="text"
default=""
label="LABEL_CLASS_SUFFIX"
description="DESC_MOD_SUFFIX">
name="@spacer"
type="spacer"
default=""
label=""
description="">
name="usercount"
type="text"
default="5"
label="LABEL_USER_COUNT"
description="DESC_USER_COUNT">
name="layout"
type="list"
default="default"
label="LABEL_USER_LAYOUT"
description="DESC_USER_LAYOUT">
value="default">Unordered List
value="ordered_list">Ordered List
you can update with your own personal info on "
These are the parameters that are on the right hand side when viewing your module in modlue manager. Here we have 4.
The first is the "module class suffix" which all modules have. The suffix the user adds here will be attached to the modules css class so you can style individual modules. The second is just a simple "spacer". The third is the number of users you wish to display in the module and finally, the fourth is the layout option.
You can have multiple layouts for one module. Each layout should go in the tmpl folder. Our 2 options here is the default, which is an unordered list with the "Website Users" description at the top. The ordered_list layout uses a numbered list and no description at the top. The changes are very subtle but I just wanted to show you a simple example.
Another thing you might be looking at is the uppercase constants like "LABEL_USER_COUNT". These are used with the language file that will be included later.
mod_siteusers.php
This file acts as a controller directing the functions and files
helper.php
This file runs the main function (getItems). This function gets the users from the database using a specified query. Joomla has a very specific syntax for interacting with the database. You can read all about it here. The code above instantiates a database object, puts the query in a variable called $query, runs the query and returns the $items as an array. The query is self explanatory. It will select the id and the username from the users table and it will be limited buy $usercount which we specify in mod_siteusers.xml. This query will be used to loop through the array of users in default.php (view file).
index.html
This html file is strictly used to prevent users from accessing the module files directly
tmpl/default.php
The default.php file is the modules "default view". It is in charge of displaying the module to the user. It is essentially html with php includes and loops. This file performs a foreach loop to diaplay the $rows array which is the array of users.
tmpl/ordered_list.php
This is the "ordered list" layout. As stated above, the only difference is that it uses a numbered list and has no description parameter.
tmpl/index.html
Same as above, it is used to prevent users from accessing the module files directly
Now that all of your files are created, add the entire "mod_siteusers" folder to a zip file using whatever zip program you use (winzip, winrar, 7zip, etc).
Congrats! Your first Joomla module is complete.Lets Start your Work on Admin Panel
Login to your Joomla admin area and goto the extension manager. From the "install" seciton, browse and upload the zip file. You should get a "Successful Install" message.
Visit your frontend and you should see a list of your website users.
Congratulations, you have successfully Completed Create a Custom Joomla 2.5 Module Course, Now you can play around with Joomla Custom Modules..to know more about Drupal and other PHP related CMS, subscribe with us...
Related Posts
Content Management System
Drupal Installations
Create a Content in Drupal 7.x
Drupal Hello Word Modules
Joomla Installation
Joomla Hello world Components
Wordpress Installations
Drupal Installations
Create a Content in Drupal 7.x
Drupal Hello Word Modules
Joomla Installation
Joomla Hello world Components
Wordpress Installations
Excelent content! Did you know about this tool? http://www.notwebdesign.com/joomla-component-creator/ What do you think about it? =)
ReplyDeleteThanks for your comments, yep i heard about it and i have seen it. This site helps to developer to create a component wihtin short time with some limition of the table creations (Free version). Thats it...
Deletehttp://www.techguywebsolutions.com/create-a-custom-joomla-2.5-module.html
ReplyDeleteis this is your own tutorial or just copied from the link i mentioned?
please can you help me in integrating my php application
ReplyDeletePlease help ma. I have a error.Please give me xml.Please.
ReplyDelete