Page 1 of 1

Controllers not loading

Posted: Fri Nov 06, 2015 5:48 am
by beo
Hey guys!

I'm trying to load a controller inside another controller.

$data['com_top_menu'] = $this->load->controller('account/com_top_menu');

However, this seems to not work when I'm trying to load a controller that is located in the same folder as the controller I'm loading it from.

Tried loading controllers from other folders and seem to not load as well. It seams to load only from the common folder.

Could this be some bug?

Re: Controllers not loading

Posted: Fri Nov 06, 2015 9:19 pm
by daniGo
I think your code are wrong. For me is working. I add search controller inside header controller in admin and is working fine.

Re: Controllers not loading

Posted: Fri Nov 06, 2015 11:10 pm
by beo
daniGo wrote:I think your code are wrong.
Why do you think so? I guess that using $this->load->controller('path/controller') is the way to load it. There not much where to the wrong here, it is just a simple line of code.

Can you try for example, to load the controller information/contact into account/account?

in /catalog/controller/account/account.php add:

Code: Select all

$data['contact'] = $this->load->controller('information/contact');
in /catalog/view/theme/default/template/account/account.tpl add:

Code: Select all

<?php echo $contact; ?>

Re: Controllers not loading

Posted: Fri Nov 06, 2015 11:43 pm
by beo
Actually it seems that the controller is loading.

If I place an echo in the middle of the loaded controller it will show the output on top of the page before the template rendered. So, it looks like the controller is loaded and just doesn't output anything through the rendered view, unless it is a controller inside the common folder.

Files are all in place, controller loads, it just doesn't output anything through the view.

Re: Controllers not loading

Posted: Sat Nov 07, 2015 2:08 am
by daniGo
The diference is here:

Code: Select all

$this->response->setOutput($this->load->view('default/template/account/account.tpl', $data));

Code: Select all

return $this->load->view('default/template/common/search.tpl', $data);

Re: Controllers not loading

Posted: Sat Nov 07, 2015 5:19 am
by beo
Got it!

Thanks a lot man!