[eluser]vincej[/eluser]
I have read your question 4 times and I am struggling to understand it clearly. I think you are struggling with the MVC pattern. 6 months ago I started CI. The Best thing you can do is buy a book called 'professional Codeigniter' by Tom Meyer. It is invaluable for getting started. Then you also need to really study the user guide. It is also excellent.
Essentially the pattern goes like this:
1 - Your controller calls a model requesting data - check the user guide for exact syntax.
2 - Your model grabs data and does a return in a variable.
3 - Your controller passes the data to the view you have featured in the controller without any specific extra syntax.
4 - If you need the data to go somewhere else then you must call that controller who in turn will pass it over to their view.
Here is an example taken from my own code :
Controller:
Code:
Controller:
function index(){
$data['title'] = "Welcome to Country Wide";
$data['navlist'] = $this->MCats->getCategoriesNav();
$data['main'] = 'home';
$this->load->vars($data);
$this->load->view('template');
}
Model:
function getCategoriesNav(){
$data = array();
$this->db->select('id,name,parentid');
$this->db->where('status', 'active');
$this->db->order_by('parentid','asc');
$this->db->order_by('name','asc');
$this->db->group_by('parentid,id');
$Q = $this->db->get('categories');
if ($Q->num_rows() > 0){
foreach ($Q->result() as $row){
if ($row->parentid > 0){
$data[0][$row->parentid]['children'][$row->id] = $row->name;
}else{
$data[0][$row->id]['name'] = $row->name;
}
}
}
$Q->free_result();
return $data;
}