August 29, 2012

August 29, 2012

All of the components that we have made will be put under the folder components. In our exercises, considere that your Joomla! folder named myjoomla, then all of our exercises component will be put under [webroot]/myjoomla/components. All of the component folder naming started with com_(component_name).

We are going to make a simple component named hello. According to the rule, then the component folder will be named as com_hello. Here are the steps in making the hello component:

1. Make new folder named com_hello under myjoomla/components folder.

2. Make the hello.php file inside the com_hello folder, and type the code as the following then save this change:

The program code explanation as the following:

  1. You must write the first line into every component file. This line will prevent people from accessing the file directly without through the URL rules which is established by Joomla.
  2. The next line, we are going to show the "Hello World." text in Joomla! page. We wiil modify the text a little bit by adding the class name into tag div. Class will be related with CSS which has been definite in template.

Executing the Component

After making the simple file for hello component, it is time for you to show it in the Joomla! page. You can call it with the following formula:


In this exercise, you can call it with:



  1. The above code on front page show an error "The requested page cannot be found."
    I am using joomla version 3.2.