Multiple views from one controller - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23) +--- Thread: Multiple views from one controller (/showthread.php?tid=9378) |
Multiple views from one controller - El Forum - 06-23-2008 [eluser]satterle[/eluser] I think I figured it out on my own! 1. the view statement should be view('delete'), not view('co/delete') 2. going to a different mvc, in this case 'cancel', requires redirect('co/cancel') ------------------------ I have a controller that deletes a record from a database. I set it up as follows: if($this->input->post('delete')) { $this->model->delete($id) $this->load->view('co/delete', $data) } else if($this->input->post('cancel')) { $this->load->view('co/cancel', $data) } else { $this->load->view('co/delete', $data) } When I load the page the first time (the else condition), no problem. When I try to load the page from the if conditions, I get an error message "unable to load the requested file: name of file". I know that the if statements are working because a) a record is deleted when I click the delete button and b) the error message displays the appropriate file name when I click on the different buttons on the form. Why don't the views load? How do I correct? Multiple views from one controller - El Forum - 06-23-2008 [eluser]nanda[/eluser] I'm not sure why its not working, I would double check that the files are where you specified and that they are named exactly right (no typos). Otherwise, sorry :-S Multiple views from one controller - El Forum - 06-23-2008 [eluser]Scriptor[/eluser] I'm guessing cancel was a controller method, and not a view If that's the case, remember the difference between a view and a controller method. Loading a view will simply look in the views folder for the file you specified. If you need to go to another method in a controller, you have to use redirect, which use a HTTP redirect, which basically tells the browser to load a completely new URL. Hope that helps, remember to always find out both what works, and why it works. |