Post by beo » Fri Nov 06, 2015 5:48 am

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?

beo
Newbie

Posts

Joined
Thu Jul 12, 2012 4:57 am

Post by daniGo » Fri Nov 06, 2015 9:19 pm

I think your code are wrong. For me is working. I add search controller inside header controller in admin and is working fine.

http://www.gombac.si


Active Member

Posts

Joined
Wed Mar 20, 2013 4:49 pm
Location - Slovenia

Post by beo » Fri Nov 06, 2015 11:10 pm

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; ?>

beo
Newbie

Posts

Joined
Thu Jul 12, 2012 4:57 am

Post by beo » Fri Nov 06, 2015 11:43 pm

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.

beo
Newbie

Posts

Joined
Thu Jul 12, 2012 4:57 am

Post by daniGo » Sat Nov 07, 2015 2:08 am

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);

http://www.gombac.si


Active Member

Posts

Joined
Wed Mar 20, 2013 4:49 pm
Location - Slovenia

Post by beo » Sat Nov 07, 2015 5:19 am

Got it!

Thanks a lot man!

beo
Newbie

Posts

Joined
Thu Jul 12, 2012 4:57 am
Who is online

Users browsing this forum: No registered users and 9 guests