Welcome Guest, Not a member yet? Register   Sign In
What do you do When Multiple Controllers are Needed?
#1

[eluser]Nalorin[/eluser]
I'm working on a site that will have multiple parts of the page be dependent upon database content. One section will be list of categorical filters. Another will be a list of other filters (for example: price, condition, etc), and the main area will be search results after the filters have been applied.

I'm not quite sure how I would accomplish this. I tried something similar to this:
Code:
<html>
<body>
  <div id='categories'> &lt;?php $this->load->controller('categories'); ?&gt; </div>
  <div id='filters'> &lt;?php $this->load->controller('filters'); ?&gt; </div>
  <div id='main_content'> &lt;?php $this->load->controller('main'); ?&gt; </div>
&lt;/body&gt;
&lt;/html&gt;
only to learn (as I expected) that controllers cannot be loaded from views.

Does anyone have any suggestions on how I may accomplish this?

Any help would be greatly appreciated! Thanks in advance!
#2

[eluser]bretticus[/eluser]
Not sure why using simple variables from your controller is insufficient. So I'll guess that what you really want is some sort of intelligent partials or widgets:

http://ellislab.com/forums/viewthread/109584

Cheers!
#3

[eluser]mddd[/eluser]
I feel like you are not getting the idea of CI.. There is only ever 1 controller active at the same time. The controller is the thing that responds to the url that is called. It is like the manager of the whole process. The controller can get information (via models) and display information (via views). So if you want to have 'blocks' (like categories, filters etc) you should put the html of that block in a view, and load the necessary information in your controller. Then load each block (view), while providing it with the necessary information.
#4

[eluser]Nalorin[/eluser]
You're right: I was looking at it in a much more modular fashion, thinking that controllers functioned more like functions you could call at whim to do your work and call the necessary views to display the information.

Your explanation makes much more sense. Thank you!




Theme © iAndrew 2016 - Forum software by © MyBB