Register in order to access new features like "Job Alert" and "Buyer Alert"

Login

Login
No account yet? Register

Latest Articles

Auction Factory Banner
Freelancer Jobs arrow Joomla arrow Joomla custom component tutorial - Part 1
Sep 10 Joomla custom component tutorial - Part 1 PDF
How to create custom Joomla components

A. The Basics
This article requires PHP knowledge and some basic knowledge of the Joomla paradigm.

We will name our component “mycomponent”

First we must understand how Joomla makes the call to a component. Since Joomla is a one entry point framework, all calls go through index.php. the “option” parameter indicates what component gets called.

In order for Joomla to find the component, there must be a folder called “com_mycomponent”, and the main component file should be called mycomponent.php

*Mind the case sensitivity of LINUX based hostings*

Joomla will give control to your component, and the output will be displayed in the template you set up in your site.

Common practice is to use the “task” parameter to indicate witch action should the component do. Joomla reads as a standard this parameter. You can rely on it that $task, $option and $Itemid (will be discussed later) are initialized before the entry into the component

So for the first step just create a folder /components/com_ mycomponent

Create the file /components/com_ mycomponent/mycomponent.php

And write this in it:

switch ($task) {
default:
case 'hello':
echo 'Hello World!';
break;
case 'bye':
echo 'Good Bye World!';
break;
}
?>

So if you now call you component in you browser with the task set to “hello” then you will get the “Hello World” in the content area , and with Task “bye” you will get a “Good Bye World” .
So we got a first running component.


B. Administration Backend

Most components have also administration options – mostly configurations or statistics. Some get the needed data in admin, some have just a configuration. Regardless, question is how it’s done.

All admin tasks will be processed through a file in /administrator/components/com_ mycomponent that you have to name admin.mycomponent.php

Comments
Add New Search
Pete  - Excellent Start!     |Guest IP67.184.162.xxx |2009-05-17 20:33:12
An excellent start to Joomla Custom Component creation. I just wish you would
have gone into more detail! Can't wait for part 2.
Mandvi  - great starting of learning     |Guest IP122.164.31.xxx |2009-07-09 04:43:17
great article to start to learn creating own template.. Its very easy to learn
from this. want some more detail
Jaime  - simple and direct     |Guest IP209.45.86.xxx |2009-07-24 19:38:28
A really good intro, because all of us prefer to make something work even if it
a only with limited functionality
Jaime  - good     |Guest IP209.45.86.xxx |2009-07-24 20:55:28
a good complement to this article, how to create a component in
joomla:

http://www.packtpub.com/article/developin
g-the-joomla-component-and-understanding-its-struc ture
developer   |Guest IP220.227.77.xxx |2009-09-09 09:45:18
good
PHP beginner   |Guest IP41.0.58.xxx |2009-12-21 19:14:47
Thanks, really helped
subas chandra dhungana  - how to call component   |Guest IP203.78.161.xxx |2010-01-14 11:09:34
I have read your joomla custom tutorial part 1 but confused how to call
component in browser after making our custom component? Please give me tutorials
step by step done.
Sonatabar  - Joomla Custom Component Basics   |Guest IP128.82.160.xxx |2010-04-02 15:18:13
This is really all you need to start writing and understanding a basic
component. Haven't found anything as basic as this, to start understanding
component writing. All other hello world's I found included scary stuff for
beginners.

Very helpful!
Write comment
Name:
Email:
 
Website:
Title:
UBBCode:
[b] [i] [u] [url] [quote] [code] [img] 
 
 
:angry::0:confused::cheer:B):evil::silly::dry::lol::kiss::D:pinch:
:(:shock::X:side::):P:unsure::woohoo::huh::whistle:;):s
:!::?::idea::arrow:
 
Please input the anti-spam code that you can read in the image.

3.26 Copyright (C) 2008 Compojoom.com / Copyright (C) 2007 Alain Georgette / Copyright (C) 2006 Frantisek Hliva. All rights reserved."

 
< Prev   Next >