Reputation: 45
I have various functions/methods in my controller.
index() --- loads the homepage view
$data['main_view'] = "home_view";
$this->load->view('layouts/main', $data);
view_all() --- loads some row count data
$this->load->model('home_model');
$data['result'] = $this->home_model->total_applications();
$this->load->view('home_view', $data);
To load my homepage i goto url : www.mydomain.com/home To view my method i have to goto : www.mydomain.com/home/view_all
I tried to load function view_all() in my view like this :
echo $result ---- and this throws out an error.
How do i load/call the fucntion view_all() when i visit www.mydomain.com/home. I have alot of functions in that controller and i want to use them on my homepage.
Upvotes: 0
Views: 62
Reputation: 45
Ok , im not sure if this is the right way, but what i did was load all results from the model into one function and call them using :
$data['result1'] = $this->home_model->total_applications();
$data['result2'] = $this->home_model->total_applications2();
$data['result3'] = $this->home_model->total_applications3();
Upvotes: 0
Reputation: 1740
You need to setup routing in your configuration. It is well described in documentation.
Upvotes: 0