Welcome Guest, Not a member yet? Register   Sign In
CI MVC: Multiple Views and/or Controllers?
#1

[eluser]ShawnMA[/eluser]
I've read similar posts but they all seem focused on headers/footers. In my app I have an admin section that consists of individual functionality for people, venues and events. Each of which is a seperate view, but all three share one controller, that contains functions specific to each. In other words 3 models, 1 controller, 3 views. Is this ideal?

The issue I'm running into is that in my controller, I'm unclear on how to load and then call into each view as needed. In using the code below, all 3 views obviously attempt to load, but into the same page, which is cuasing it to error out.

Any and all assistance is appreciated!

Code:
class Admin extends CI_Controller{          
function index(){                  
$data['states'] = $this->db->get('states')->result(); /*these are used to populate dropdowns */            
$data['venues'] = $this->db->get('venue')->result();            
$data['events'] = $this->db->get('event')->result();            
$this->load->view('admin/people', $data);            
$this->load->view('admin/venues', $data);            
$this->load->view('admin/events', $data);        
}
I also tried setting something like this up: http://stackoverflow.com/questions/12172...odeigniter

But it doesn't seem to work well either.
#2

[eluser]osci[/eluser]
what's the error?
#3

[eluser]ShawnMA[/eluser]
It attempts to load all 3 views into a one page view, so the first view (people) loads fine, but below it the 2 remaining views are loaded, but they do not render correctly.

Ideally I want to have main menu that each link points to and loads the specific view.

Any direction on this is greatly appreciated. Thanks.
#4

[eluser]osci[/eluser]
I guess you mean that all your views are full html pages with body tag etc...

If that's the case they should be broken parts of a page.


For insight: Wiki FAQ and go to Design section
#5

[eluser]ShawnMA[/eluser]
Thanks for the link to the Wiki FAQ. It looks to be of immense help.




Theme © iAndrew 2016 - Forum software by © MyBB