Joomla 2.5.6 Component Development

659 views
Skip to first unread message

nowphp

unread,
Jul 14, 2012, 11:54:56 AM7/14/12
to joomla-de...@googlegroups.com
I am new in Joomla. I am trying to develop a component in Joomla 2.5.6.

$input = JFactory::getApplication()->input;
$controller->execute($input->getCmd('task'));

What is the meaning of these two lines ??

Thanks

Foysal

Nick Savov

unread,
Jul 14, 2012, 12:51:27 PM7/14/12
to joomla-de...@googlegroups.com
Hi Foysal,

I'm new to this so please pardon me if I'm not 100% accurate.

The first line creates the JInput object. Checkout the following doc:
http://docs.joomla.org/JInput_Background_for_Joomla_Platform

The second line executes the task.

Kind regards,
Nick
> --
> You received this message because you are subscribed to the Google Groups
> "Joomla! General Development" group.
> To view this discussion on the web, visit
> https://groups.google.com/d/msg/joomla-dev-general/-/80BVlonNIHEJ.
> To post to this group, send an email to
> joomla-de...@googlegroups.com.
> To unsubscribe from this group, send email to
> joomla-dev-gene...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/joomla-dev-general?hl=en-GB.
>
>

nowphp

unread,
Jul 14, 2012, 1:47:10 PM7/14/12
to joomla-de...@googlegroups.com
Dear Nick Savov,

Thanks for reply. Actually I am new in joomla programming. I know codeigniter.
Now I would like to have some joomla mvc programming.
What is the meaning of
getCmd('task') ??

Thanks

Foysal


On Saturday, 14 July 2012 22:51:27 UTC+6, Nick Savov wrote:
Hi Foysal,

I'm new to this so please pardon me if I'm not 100% accurate.

The first line creates the JInput object.  Checkout the following doc:
http://docs.joomla.org/JInput_Background_for_Joomla_Platform

The second line executes the task.

Kind regards,
Nick


> I am new in Joomla. I am trying to develop a component in Joomla 2.5.6.
>
> $input = JFactory::getApplication()->input;
> $controller->execute($input->getCmd('task'));
>
> What is the meaning of these two lines ??
>
> Thanks
>
> Foysal
>
> --
> You received this message because you are subscribed to the Google Groups
> "Joomla! General Development" group.
> To view this discussion on the web, visit
> https://groups.google.com/d/msg/joomla-dev-general/-/80BVlonNIHEJ.
> To post to this group, send an email to
> joomla-dev-general@googlegroups.com.
> To unsubscribe from this group, send email to
> joomla-dev-general+unsub...@googlegroups.com.

Nick Savov

unread,
Jul 14, 2012, 1:54:29 PM7/14/12
to joomla-de...@googlegroups.com
Hi Foysal,

You're welcome!

getCmd gets a filtered variable. The cmd filter only allows the
characters [A-Za-z0-9.-_]

Check out the following two docs:
http://docs.joomla.org/API15:JRequest/getCmd
http://docs.joomla.org/Secure_coding_guidelines

Kind regards,
Nick
>> > joomla-de...@googlegroups.com.
>> > To unsubscribe from this group, send email to
>> > joomla-dev-gene...@googlegroups.com.
>> > For more options, visit this group at
>> > http://groups.google.com/group/joomla-dev-general?hl=en-GB.
>> >
>> >
>>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Joomla! General Development" group.
> To view this discussion on the web, visit
> https://groups.google.com/d/msg/joomla-dev-general/-/pLU4NuTGAM4J.
> To post to this group, send an email to
> joomla-de...@googlegroups.com.
> To unsubscribe from this group, send email to
> joomla-dev-gene...@googlegroups.com.

nowphp

unread,
Jul 14, 2012, 3:34:41 PM7/14/12
to joomla-de...@googlegroups.com
Dear Nick Savov,

Thanks for reply.

I think 'task' is a variable here
getCmd('task'). My question is where is the source of this variable ?? Where is the production place of this variable ?? What is the value of this variable ??

Thanks

Foysal
>> > joomla-dev-general@googlegroups.com.
>> > To unsubscribe from this group, send email to
>> > joomla-dev-general+unsub...@googlegroups.com.
>> > For more options, visit this group at
>> > http://groups.google.com/group/joomla-dev-general?hl=en-GB.
>> >
>> >
>>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Joomla! General Development" group.
> To view this discussion on the web, visit
> https://groups.google.com/d/msg/joomla-dev-general/-/pLU4NuTGAM4J.
> To post to this group, send an email to
> joomla-dev-general@googlegroups.com.
> To unsubscribe from this group, send email to
> joomla-dev-general+unsub...@googlegroups.com.

Rouven Weßling

unread,
Jul 14, 2012, 6:17:33 PM7/14/12
to joomla-de...@googlegroups.com
The task comes from the HTTP request via GET or POST.

Rouven

To view this discussion on the web, visit https://groups.google.com/d/msg/joomla-dev-general/-/HBxKMwnfUrcJ.
To post to this group, send an email to joomla-de...@googlegroups.com.
To unsubscribe from this group, send email to joomla-dev-gene...@googlegroups.com.

nowphp

unread,
Jul 14, 2012, 10:09:00 PM7/14/12
to joomla-de...@googlegroups.com
Dear Rouven Weßling,

Thanks for reply.

I felt that previously, t
he task comes from the HTTP request via GET or POST. But why is it 'task' ?? Not 'taskee' or 'atask' or 'mouse' or something else. Where is the source of this 'task' ??

Thanks

Foysal

Nick Savov

unread,
Jul 14, 2012, 10:54:44 PM7/14/12
to joomla-de...@googlegroups.com
Hi Foysal,

Check out:
http://api.joomla.org/Joomla-Platform/Application/JController.html#$task

If you're wanting to know more of the "whys" you should check out the
following Joomla Programming book:
http://www.amazon.com/Joomla-Programming-Press-Mark-Dexter/dp/013278081X/ref=sr_1_1?ie=UTF8&qid=1342320678&sr=8-1&keywords=joomla+development

Hope this helps!

Kind regards,
Nick

> Dear Rouven We�ling,
>
> Thanks for reply.
>
> I felt that previously, the task comes from the HTTP request via GET or
> POST. But why is it 'task' ?? Not 'taskee' or 'atask' or 'mouse' or
> something else. Where is the source of this 'task' ??
>
> Thanks
>
> Foysal
>
>>> >> > joomla-de...@googlegroups.com.
>>> >> > To unsubscribe from this group, send email to
>>> >> > joomla-dev-gene...@googlegroups.com.
>>> >> > For more options, visit this group at
>>> >> > http://groups.google.com/group/joomla-dev-general?hl=en-GB.
>>> >> >
>>> >> >
>>> >>
>>> >
>>> > --
>>> > You received this message because you are subscribed to the Google
>>> Groups
>>> > "Joomla! General Development" group.
>>> > To view this discussion on the web, visit
>>> > https://groups.google.com/d/msg/joomla-dev-general/-/pLU4NuTGAM4J.
>>> > To post to this group, send an email to
>>> > joomla-de...@googlegroups.com.
>>> > To unsubscribe from this group, send email to
>>> > joomla-dev-gene...@googlegroups.com.
>>> > For more options, visit this group at
>>> > http://groups.google.com/group/joomla-dev-general?hl=en-GB.
>>> >
>>> >
>>>
>>
>> --
>> You received this message because you are subscribed to the Google
>> Groups
>> "Joomla! General Development" group.
>> To view this discussion on the web, visit
>> https://groups.google.com/d/msg/joomla-dev-general/-/HBxKMwnfUrcJ.
>> To post to this group, send an email to
>> joomla-de...@googlegroups.com.
>> To unsubscribe from this group, send email to
>> joomla-dev-gene...@googlegroups.com.
>> For more options, visit this group at
>> http://groups.google.com/group/joomla-dev-general?hl=en-GB.
>>
>>
>>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Joomla! General Development" group.
> To view this discussion on the web, visit
> https://groups.google.com/d/msg/joomla-dev-general/-/k_T5MSOIbHAJ.
> To post to this group, send an email to
> joomla-de...@googlegroups.com.
> To unsubscribe from this group, send email to
> joomla-dev-gene...@googlegroups.com.

MOHAMED AKRAM

unread,
Jul 15, 2012, 12:41:19 AM7/15/12
to joomla-de...@googlegroups.com
The Jrequst::getCmd, is way of getting data from a php Hash (POST,GET) etc...,
There are more than 6 nor 7 method of JRequest , The base method of this is JRequest getVar,

In php when  a form submit happen, if the the form method is POST, How we get the data in php is,  $_POST['name'],  but in joomla environment, we can get the same thing using JRequest::getVar('name') method, but other methods are jrequest::getInt, jrequest::getString,jrequest::getWord, jrequest::getCmd(), etc.., are getting the post data in a specific filteration......




On Sun, Jul 15, 2012 at 8:24 AM, Nick Savov <ni...@iowawebcompany.com> wrote:
Hi Foysal,

Check out:
http://api.joomla.org/Joomla-Platform/Application/JController.html#$task

If you're wanting to know more of the "whys" you should check out the
following Joomla Programming book:
http://www.amazon.com/Joomla-Programming-Press-Mark-Dexter/dp/013278081X/ref=sr_1_1?ie=UTF8&qid=1342320678&sr=8-1&keywords=joomla+development

Hope this helps!

Kind regards,
Nick

> Dear Rouven Weßling,

>
> Thanks for reply.
>
> I felt that previously, the task comes from the HTTP request via GET or
> POST. But why is it 'task' ?? Not 'taskee' or 'atask' or 'mouse' or
> something else. Where is the source of this 'task' ??
>
> Thanks
>
> Foysal
>

nowphp

unread,
Jul 15, 2012, 12:53:05 PM7/15/12
to joomla-de...@googlegroups.com
Dear Mohamed Akram

Thanks for reply. I am following this tutorial http://docs.joomla.org/Developing_a_Model-View-Controller_%28MVC%29_Component_for_Joomla!2.5_-_Part_02

I got a line of code there $controller->execute($input->getCmd('task'));

Can you say where is the origin of 'task' here ??

Thanks

Foysal

>>> >> > To unsubscribe from this group, send email to

>>> >> > For more options, visit this group at
>>> >> > http://groups.google.com/group/joomla-dev-general?hl=en-GB.
>>> >> >
>>> >> >
>>> >>
>>> >
>>> > --
>>> > You received this message because you are subscribed to the Google
>>> Groups
>>> > "Joomla! General Development" group.
>>> > To view this discussion on the web, visit
>>> > https://groups.google.com/d/msg/joomla-dev-general/-/pLU4NuTGAM4J.
>>> > To post to this group, send an email to

>>> > To unsubscribe from this group, send email to

>>> > For more options, visit this group at
>>> > http://groups.google.com/group/joomla-dev-general?hl=en-GB.
>>> >
>>> >
>>>
>>
>> --
>> You received this message because you are subscribed to the Google
>> Groups
>> "Joomla! General Development" group.
>> To view this discussion on the web, visit
>> https://groups.google.com/d/msg/joomla-dev-general/-/HBxKMwnfUrcJ.
>> To post to this group, send an email to

>> To unsubscribe from this group, send email to

>> For more options, visit this group at
>> http://groups.google.com/group/joomla-dev-general?hl=en-GB.
>>
>>
>>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Joomla! General Development" group.
> To view this discussion on the web, visit
> https://groups.google.com/d/msg/joomla-dev-general/-/k_T5MSOIbHAJ.
> To post to this group, send an email to

> To unsubscribe from this group, send email to

> For more options, visit this group at
> http://groups.google.com/group/joomla-dev-general?hl=en-GB.
>
>

--
You received this message because you are subscribed to the Google Groups "Joomla! General Development" group.
To post to this group, send an email to joomla-dev-general@googlegroups.com.
To unsubscribe from this group, send email to joomla-dev-general+unsub...@googlegroups.com.

Rob Poort

unread,
Jul 15, 2012, 1:03:08 PM7/15/12
to joomla-de...@googlegroups.com
Hi  Foysal,

I think the 'task' in your example doesn't come from anywhere, and is void in this case. "getCmd('task')" is added in that part of the tutorial for future use, e.g. when there really is a task to perform. It is most commonly used in the backend of a component, where you can find it in the toolbar. Further on in the tutorial you are following, you will see examples.
You can test it yourself by making a form in the frontend, and adding a hidden field with: " name="task" value="do_something" ".

2012/7/15 nowphp <now...@gmail.com>
To view this discussion on the web, visit https://groups.google.com/d/msg/joomla-dev-general/-/RjQPG7pSrFYJ.

To post to this group, send an email to joomla-de...@googlegroups.com.
To unsubscribe from this group, send email to joomla-dev-gene...@googlegroups.com.

Nick Savov

unread,
Jul 15, 2012, 1:57:22 PM7/15/12
to joomla-de...@googlegroups.com
Looks like Task comes from:
http://api.joomla.org/Joomla-Platform/Application/JController.html#$task

Doesn't it?

Kind regards,
Nick


> Hi Foysal,
>
> I think the 'task' in your example doesn't come from anywhere, and is void
> in this case. "getCmd('task')" is added in that part of the tutorial for
> future use, e.g. when there really is a task to perform. It is most
> commonly used in the backend of a component, where you can find it in the
> toolbar. Further on in the tutorial you are following, you will see
> examples.
> You can test it yourself by making a form in the frontend, and adding a
> hidden field with: " name="task" value="do_something" ".
>
> 2012/7/15 nowphp <now...@gmail.com>
>
>> Dear Mohamed Akram
>>
>> Thanks for reply. I am following this tutorial http://docs.joomla.org/**
>> Developing_a_Model-View-Control**ler_%28MVC%29_Component_for_Jo**
>> omla!2.5_-_Part_02<http://docs.joomla.org/Developing_a_Model-View-Controller_%28MVC%29_Component_for_Joomla%212.5_-_Part_02>
>>
>> I got a line of code there
>> $controller->execute($input->g**etCmd('task'));
>>
>> Can you say where is the origin of 'task' here ??
>> Thanks
>>
>> Foysal
>>
>>
>> On Sunday, 15 July 2012 10:41:19 UTC+6, Mohamed Akram wrote:
>>>
>>> The Jrequst::getCmd, is way of getting data from a php Hash (POST,GET)
>>> etc...,
>>> There are more than 6 nor 7 method of JRequest , The base method of
>>> this
>>> is JRequest getVar,
>>>
>>> In php when a form submit happen, if the the form method is POST, How
>>> we
>>> get the data in php is, $_POST['name'], but in joomla environment, we
>>> can
>>> get the same thing using JRequest::getVar('name') method, but other
>>> methods
>>> are jrequest::getInt, jrequest::getString,jrequest::**getWord,
>>> jrequest::getCmd(), etc.., are getting the post data in a specific
>>> filteration......
>>>
>>>
>>>
>>>
>>> On Sun, Jul 15, 2012 at 8:24 AM, Nick Savov
>>> <ni...@iowawebcompany.com>wrote:
>>>
>>>> Hi Foysal,
>>>>
>>>> Check out:
>>>> http://api.joomla.org/Joomla-**Platform/Application/**
>>>> JController.html#$task<http://api.joomla.org/Joomla-Platform/Application/JController.html#$task>
>>>>
>>>> If you're wanting to know more of the "whys" you should check out the
>>>> following Joomla Programming book:
>>>> http://www.amazon.com/Joomla-**Programming-Press-Mark-Dexter/**
>>>> dp/013278081X/ref=sr_1_1?ie=**UTF8&qid=1342320678&sr=8-1&**
>>>> keywords=joomla+development<http://www.amazon.com/Joomla-Programming-Press-Mark-Dexter/dp/013278081X/ref=sr_1_1?ie=UTF8&qid=1342320678&sr=8-1&keywords=joomla+development>
>>>>
>>>> Hope this helps!
>>>>
>>>> Kind regards,
>>>> Nick
>>>>
>>>> > Dear Rouven We�ling,
>>>> >>> http://docs.joomla.org/API15:**JRequest/getCmd<http://docs.joomla.org/API15:JRequest/getCmd>
>>>> >>> http://docs.joomla.org/Secure_**coding_guidelines<http://docs.joomla.org/Secure_coding_guidelines>
>>>> >>>
>>>> >>> Kind regards,
>>>> >>> Nick
>>>> >>>
>>>> >>> > Dear Nick Savov,
>>>> >>> >
>>>> >>> > Thanks for reply. Actually I am new in joomla programming. I
>>>> know
>>>> >>> > codeigniter.
>>>> >>> > Now I would like to have some joomla mvc programming.
>>>> >>> > What is the meaning of getCmd('task') ??
>>>> >>> >
>>>> >>> > Thanks
>>>> >>> >
>>>> >>> > Foysal
>>>> >>> >
>>>> >>> > On Saturday, 14 July 2012 22:51:27 UTC+6, Nick Savov wrote:
>>>> >>> >>
>>>> >>> >> Hi Foysal,
>>>> >>> >>
>>>> >>> >> I'm new to this so please pardon me if I'm not 100% accurate.
>>>> >>> >>
>>>> >>> >> The first line creates the JInput object. Checkout the
>>>> following
>>>> >>> doc:
>>>> >>> >> http://docs.joomla.org/JInput_**Background_for_Joomla_Platform<http://docs.joomla.org/JInput_Background_for_Joomla_Platform>
>>>> >>> >>
>>>> >>> >> The second line executes the task.
>>>> >>> >>
>>>> >>> >> Kind regards,
>>>> >>> >> Nick
>>>> >>> >>
>>>> >>> >>
>>>> >>> >> > I am new in Joomla. I am trying to develop a component in
>>>> Joomla
>>>> >>> >> 2.5.6.
>>>> >>> >> >
>>>> >>> >> > $input = JFactory::getApplication()->**input;
>>>> >>> >> > $controller->execute($input->**getCmd('task'));
>>>> >>> >> >
>>>> >>> >> > What is the meaning of these two lines ??
>>>> >>> >> >
>>>> >>> >> > Thanks
>>>> >>> >> >
>>>> >>> >> > Foysal
>>>> >>> >> >
>>>> >>> >> > --
>>>> >>> >> > You received this message because you are subscribed to the
>>>> Google
>>>> >>> >> Groups
>>>> >>> >> > "Joomla! General Development" group.
>>>> >>> >> > To view this discussion on the web, visit
>>>> >>> >> > https://groups.google.com/d/**msg/joomla-dev-general/-/**
>>>> 80BVlonNIHEJ<https://groups.google.com/d/msg/joomla-dev-general/-/80BVlonNIHEJ>
>>>> .
>>>> >>> >> > To post to this group, send an email to
>>>> >>> >> > joomla-dev-general@**googlegroups.com<joomla-de...@googlegroups.com>
>>>> .
>>>> >>> >> > To unsubscribe from this group, send email to
>>>> >>> >> > joomla-dev-general+**unsub...@googlegroups.com<joomla-dev-general%2Bunsu...@googlegroups.com>
>>>> .
>>>> >>> >> > For more options, visit this group at
>>>> >>> >> > http://groups.google.com/**group/joomla-dev-general?hl=**en-GB<http://groups.google.com/group/joomla-dev-general?hl=en-GB>
>>>> .
>>>> >>> >> >
>>>> >>> >> >
>>>> >>> >>
>>>> >>> >
>>>> >>> > --
>>>> >>> > You received this message because you are subscribed to the
>>>> Google
>>>> >>> Groups
>>>> >>> > "Joomla! General Development" group.
>>>> >>> > To view this discussion on the web, visit
>>>> >>> > https://groups.google.com/d/**msg/joomla-dev-general/-/**
>>>> pLU4NuTGAM4J<https://groups.google.com/d/msg/joomla-dev-general/-/pLU4NuTGAM4J>
>>>> .
>>>> >>> > To post to this group, send an email to
>>>> >>> > joomla-dev-general@**googlegroups.com<joomla-de...@googlegroups.com>
>>>> .
>>>> >>> > To unsubscribe from this group, send email to
>>>> >>> > joomla-dev-general+**unsub...@googlegroups.com<joomla-dev-general%2Bunsu...@googlegroups.com>
>>>> .
>>>> >>> > For more options, visit this group at
>>>> >>> > http://groups.google.com/**group/joomla-dev-general?hl=**en-GB<http://groups.google.com/group/joomla-dev-general?hl=en-GB>
>>>> .
>>>> >>> >
>>>> >>> >
>>>> >>>
>>>> >>
>>>> >> --
>>>> >> You received this message because you are subscribed to the Google
>>>> >> Groups
>>>> >> "Joomla! General Development" group.
>>>> >> To view this discussion on the web, visit
>>>> >> https://groups.google.com/d/**msg/joomla-dev-general/-/**HBxKMwnfUrcJ<https://groups.google.com/d/msg/joomla-dev-general/-/HBxKMwnfUrcJ>
>>>> .
>>>> >> To post to this group, send an email to
>>>> >> joomla-dev-general@**googlegroups.com<joomla-de...@googlegroups.com>
>>>> .
>>>> >> To unsubscribe from this group, send email to
>>>> >> joomla-dev-general+**unsub...@googlegroups.com<joomla-dev-general%2Bunsu...@googlegroups.com>
>>>> .
>>>> >> For more options, visit this group at
>>>> >> http://groups.google.com/**group/joomla-dev-general?hl=**en-GB<http://groups.google.com/group/joomla-dev-general?hl=en-GB>
>>>> .
>>>> >>
>>>> >>
>>>> >>
>>>> >
>>>> > --
>>>> > You received this message because you are subscribed to the Google
>>>> Groups
>>>> > "Joomla! General Development" group.
>>>> > To view this discussion on the web, visit
>>>> > https://groups.google.com/d/**msg/joomla-dev-general/-/k_**T5MSOIbHAJ<https://groups.google.com/d/msg/joomla-dev-general/-/k_T5MSOIbHAJ>
>>>> .
>>>> > To post to this group, send an email to
>>>> > joomla-dev-general@**googlegroups.com<joomla-de...@googlegroups.com>
>>>> .
>>>> > To unsubscribe from this group, send email to
>>>> > joomla-dev-general+**unsub...@googlegroups.com<joomla-dev-general%2Bunsu...@googlegroups.com>
>>>> .
>>>> > For more options, visit this group at
>>>> > http://groups.google.com/**group/joomla-dev-general?hl=**en-GB<http://groups.google.com/group/joomla-dev-general?hl=en-GB>
>>>> .
>>>> >
>>>> >
>>>>
>>>> --
>>>> You received this message because you are subscribed to the Google
>>>> Groups "Joomla! General Development" group.
>>>> To post to this group, send an email to joomla-dev-general@**
>>>> googlegroups.com <joomla-de...@googlegroups.com>.
>>>> To unsubscribe from this group, send email to joomla-dev-general+**
>>>> unsub...@googlegroups.com<joomla-dev-general%2Bunsu...@googlegroups.com>
>>>> .
>>>> For more options, visit this group at http://groups.google.com/**
>>>> group/joomla-dev-general?hl=**en-GB<http://groups.google.com/group/joomla-dev-general?hl=en-GB>
>>>> .
>>>>
>>>>
>>> --
>> You received this message because you are subscribed to the Google
>> Groups
>> "Joomla! General Development" group.
>> To view this discussion on the web, visit
>> https://groups.google.com/d/msg/joomla-dev-general/-/RjQPG7pSrFYJ.
>>
>> To post to this group, send an email to
>> joomla-de...@googlegroups.com.
>> To unsubscribe from this group, send email to
>> joomla-dev-gene...@googlegroups.com.
>> For more options, visit this group at
>> http://groups.google.com/group/joomla-dev-general?hl=en-GB.
>>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Joomla! General Development" group.
> To post to this group, send an email to

MOHAMED AKRAM

unread,
Jul 16, 2012, 12:14:41 AM7/16/12
to joomla-de...@googlegroups.com
Hi Foysal, Sorry for Late reply,
In this case ,
the file which is hold

$input = JFactory::getApplication()->
input;
$controller->execute($input->getCmd('task'));

Is the entry point to the component (MVC), here when ur component is called,
Joomla looks for a task perameter in the Global Hash (GET, POST), if its not set the default task which ispublic function display will be executed , if joomla found a task perameter, the joomla look for a function in the controller with name which set in the task perameter,

If u need a good place to continue with Joomla MVC, u try to get Packtpub.Mastering.Joomla.1.5.2nd.Edition.May.2010 ebook, their u can get good clarification and understanding, Dont worry about Joomla version, its not big deal if u could learn Joomla 1.5 MVC Trawly, then u could easily move to Joomla 2.5, Only some of the Libabraries are changed from Joomla 1.5 and newever version after that..





>>>> > Dear Rouven Weßling,

foysal foysal

unread,
Jul 16, 2012, 2:03:28 AM7/16/12
to joomla-de...@googlegroups.com
Thanks to all who try to help me. After a long search, I got something(Though I am not so clear so far).

There is a protected variable  named $task in line 137 of controller.php file which is kept here E:\xampp\htdocs\new_joomla\libraries\joomla\application\component .

When we are using this function public static function getInstance($prefix,$config = array())   we are putting some thing to that protected variable name $task in line 137 of controller.php

Later when we are trying to get that value using this syntax 
$controller->execute($input->getCmd('task'));
If I echo that line I am getting the controller class name that is 'HelloWorldController' .

But I little confused so far, In which point(Where) joomla inserting value and which value joomla inserting in $task variable??

Thanks

Foysal

foysal foysal

unread,
Jul 16, 2012, 2:06:37 AM7/16/12
to joomla-de...@googlegroups.com
I saw several component code in newly installed joomla. I got this line of code $controller->execute(JRequest::getCmd('task')); several times. This returns the name of the controller class.

How do you develop a component ??

thanks

Foysal

MOHAMED AKRAM

unread,
Jul 16, 2012, 2:20:23 AM7/16/12
to joomla-de...@googlegroups.com
Dear Foysal,

Just Look at the code of mine in one of a component entry point,

<?php
defined('_JEXEC') or die;

$view = JRequest::getCmd('view');
$task = JRequest::getCmd('task');
$session   = JFactory::getSession();
$employer  = $session->get('employer_logined', false, 'appcurrentlogin');
if(!$employer){
    if(!($view == 'registration' || $task == 'registration.activate' || $task == 'registration.register')){
        $app = JFactory::getApplication();
        $app ->redirect('index.php', 'You are not authorized to view this page', 'Error');
    }
}

jimport('joomla.application.component.controller');
JLoader::register('JobsHelper', dirname(__FILE__) . '/helpers/jobs.php');

$controller = JController::getInstance('Jobs');
$controller ->execute(JRequest::getCmd('task'));
$controller ->redirect();

?>


I think You are confused with Task variable, it just a task. Normally Joomla handle functions by passing a value with the name of task via the hash.. assume you want to submit a form to a particular function in the default controller, , your form action would look like something following...
<form action="index.php?option=com_xxx&task=saveEmployerDetails" method="post">

<!--or you can even past the task value look like this in a hidden field, -->

<input type="hidden" name="task" value="saveEmployerDetails" />


</form>
if task is not set , the Jequest::getCMD('task'); will return null, and joomla will try to execute a default function called display(); if its not also defined, then nothing is executed.....
Reply all
Reply to author
Forward
0 new messages