calling the controller 1.5 vs 3.6

22 views
Skip to first unread message

becyn82

unread,
Dec 21, 2016, 12:46:43 PM12/21/16
to Joomla! General Development
I am somewhat cofused by looking at the Joomla component tutorial and some "real world" components.

Is the JImport class deprecited where:
[code] jimport('joomla.application.component.controller');
class HelloworldControllerHelloworld extends JControllerLegacy
{

    function __construct() {
        parent::__construct();

    }[/code]

now to be written:

[code]
$controller = JControllerLegacy::getInstance('HelloWorld');[/code]

Which seems to call and extend the controller in one line rather than each done separately?

In other words, it's a much more stramlined way to do the same thing?

Hannes Papenberg

unread,
Dec 21, 2016, 1:26:11 PM12/21/16
to Joomla! General Development
One is the controller, the other is the part where the controller is called. These do not do the same thing. However, you do not need jimport() anymore. Most of the time, this is done by auto loading.

Hannes

--
You received this message because you are subscribed to the Google Groups "Joomla! General Development" group.
To unsubscribe from this group and stop receiving emails from it, send an email to joomla-dev-general+unsub...@googlegroups.com.
To post to this group, send email to joomla-dev-general@googlegroups.com.
Visit this group at https://groups.google.com/group/joomla-dev-general.
For more options, visit https://groups.google.com/d/optout.

Hannes Papenberg

unread,
Dec 21, 2016, 3:11:45 PM12/21/16
to Joomla! General Development
To be a bit more precise: You are looking at different files here. The
first can be found in controller.php and should look pretty similar in
3.x to 1.5. Please make sure that you are writing PHP5 code. The missing
access modifier to your constructor hints at PHP4 code...

The other file is your helloworld.php file, which did stuff a lot more
specifically in 1.5 and now in 3.x it loads the controller for you
automatically.

Hannes

Am 21.12.2016 um 19:26 schrieb Hannes Papenberg:
> One is the controller, the other is the part where the controller is
> called. These do not do the same thing. However, you do not need
> jimport() anymore. Most of the time, this is done by auto loading.
>
> Hannes
>
> Am 21.12.2016 6:46 nachm. schrieb "becyn82" <bec...@gmail.com
> <mailto:bec...@gmail.com>>:
>
> I am somewhat cofused by looking at the Joomla component tutorial
> and some "real world" components.
>
> Is the JImport class deprecited where:
> [code] jimport('joomla.application.component.controller');
> class HelloworldControllerHelloworld extends JControllerLegacy
> {
>
> function __construct() {
> parent::__construct();
>
> }[/code]
>
> now to be written:
>
> [code]
>
> $controller = JControllerLegacy::getInstance('HelloWorld');[/code]
>
> Which seems to call and extend the controller in one line rather
> than each done separately?
>
> In other words, it's a much more stramlined way to do the same thing?
>
> --
> You received this message because you are subscribed to the Google
> Groups "Joomla! General Development" group.
> To unsubscribe from this group and stop receiving emails from it,
> send an email to joomla-dev-gene...@googlegroups.com
> <mailto:joomla-dev-gene...@googlegroups.com>.
> To post to this group, send email to
> joomla-de...@googlegroups.com
> <mailto:joomla-de...@googlegroups.com>.
> <https://groups.google.com/group/joomla-dev-general>.
> For more options, visit https://groups.google.com/d/optout
> <https://groups.google.com/d/optout>.
>
>

Reply all
Reply to author
Forward
0 new messages