Welcome Guest, Not a member yet? Register   Sign In
Using views: stop execution after loading a view but still get the layout
#1

[eluser]JustinWyllie[/eluser]
Hi

I want to do something like this:

try {
something
}
catch (\Exception $e) {
$this->load->view('error');
}

further code which is not executed

The problem is if I put an exit statement after loading the error view the layout is not loaded. But I if I don't then the rest of the code is executed.

How do I load a view and the layout and then stop?

Thanks

-JustinWyllie
#2

[eluser]InsiteFX[/eluser]
You can return the whole view to your method in a string.

Code:
$error_view = $this->load->view('your_view', $data, TRUE);

The TRUE on the end tell's ci to return the view without displaying it...

After you do what you need to do you can then load that view.
Code:
$this->load->view('$error_view');
#3

[eluser]Aken[/eluser]
Try return; instead of exit;




Theme © iAndrew 2016 - Forum software by © MyBB