• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
view and terminate

#1
On CI3 if I want to view pages :

PHP Code:
$this->load->view('paket/list.min.html'); 


That automatically exit. So I do check like this

PHP Code:
if( ! $check ){
 
    $this->load->view('page_not_found.min.html');
}
// process something
$this->load->view('page_success'); 
And when check fails, then page_success wont executed.
How to do that in CI4? Did it safe to just call exit() ?
Reply

#2
(07-25-2018, 05:30 PM)anthos1984 Wrote: On CI3 if I want to view pages :

PHP Code:
$this->load->view('paket/list.min.html'); 


That automatically exit. So I do check like this

PHP Code:
if( ! $check ){
 
    $this->load->view('page_not_found.min.html');
}
// process something
$this->load->view('page_success'); 
And when check fails, then page_success wont executed.
How to do that in CI4? Did it safe to just call exit() ?


You can use:
PHP Code:
if( ! $check ){
 
    return view('page_not_found.min.html');
}
// process something
return view('page_success'); 

Thanks
Reply

#3
Check the manual for the array of parameters that can be passed so that the view function returns a string.. which may later be tested or displayed.

Adding an else clause to the if statement may also help.
CI4 Develop Site - progressing nicely - Thank you Smile
https://johns-jokes.cf/pictures

Reply


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


Users browsing this thread:
1 Guest(s)


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2019 MyBB Group.