0

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.

2 Answers 2

0

You need to setup routing in your configuration. It is well described in documentation.

Sign up to request clarification or add additional context in comments.

4 Comments

I just want to load a couple of my created functions in my home controller on my homepage view.
put your function1 result into $data['response1'], function2 result into $data['response2']. Then you can pass $data to your view and display what you need in template.
could you please provide an example
0

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.