Here we are going to try to write the program code for Joomla simplest component. Hopefully, after you follow this course, you have better understanding the Joomla! programming structure and Joomla Component.
Create a Simple Component :
There are four basic files that are used in the standard pattern of module development:
mod_helloworld.php - This file is the main entry point for the module. It will perform any necessary initialization routines, call helper routines to collect any necessary data, and include the template which will display the module output.
mod_helloworld.xml - This file contains information about the module. It defines the files that need to be installed by the Joomla! installer and specifies configuration parameters for the module.
helper.php - This file contains the helper class which is used to do the actual work in retrieving the information to be displayed in the module (usually from the database or some other source).
tmpl/default.php - This is the module template. This file will take the data collected by mod_helloworld.php and generate the HTML to be displayed on the page.
Right now you can below steps to create a simple component.
Creating mod_helloworld.php
The mod_helloworld.php file will perform three tasks:
include the helper.php file which contains the class to be used to collect the necessary data
invoke the appropriate helper class method to retrieve the data
include the template to display the output.
Step 1: Create new folder with name of com_hello under {joomla-folder}/components folder.
Step 2: Next create a hello.php file inside the above created {joomla-folder}/components folder, and type / Copy the code as the following then save as it is.
//This line will prevent people from accessing the file directly without through the URL rules which is established by Joomla.
defined( '_JEXEC' ) or die( 'Restricted access' );
echo '
Hello, World!
';?>
Now its time to tell joomla, show my codes on my browser..Yes! please follow the below rules to run your simple components.
Step 3:
http://[servername]/[joomla-folder]/index.php?option=com_hello
you can run if you use your system as a server and you have installed joomla under myjoomla : [servername] -> http;//loclahost/myjoomla/index.php?option=com_hello
Congratulation, you have successfully created a hello world Joomla Component. you can learn simple form components very shortly...
Related Posts
Content Management System
Drupal Installations
Drupal Hello Word Modules
Joomla Installation
Joomla Hello world Components
Wordpress Installations
Drupal Installations
Drupal Hello Word Modules
Joomla Installation
Joomla Hello world Components
Wordpress Installations
No comments:
Post a Comment