CodeIgniter Forums
returning views as a data - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: CodeIgniter 4 (https://forum.codeigniter.com/forumdisplay.php?fid=28)
+--- Forum: CodeIgniter 4 Support (https://forum.codeigniter.com/forumdisplay.php?fid=30)
+--- Thread: returning views as a data (/showthread.php?tid=75618)



returning views as a data - dp41646 - 02-26-2020

Hi!
I've just installed for first time CI4, and one thing I can't see in docs is old feature of returning views as a data.
This was done by adding third bool parameter (true) when loading view.
I can see that now there are array as a third option parameter, so is there any option similar to this old feature?

Thx


RE: returning views as a data - zahhar - 02-27-2020

(02-26-2020, 02:38 PM)dp41646 Wrote: Hi!
I've just installed for first time CI4, and one thing I can't see in docs is old feature of returning views as a data.
This was done by adding third bool parameter (true) when loading view.
I can see that now there are array as a third option parameter, so is there any option similar to this old feature?

Thx

In CI4 views are actually returning data, so you could do this in controller:
PHP Code:
$pageContent $view->render('myview'); //now $pageContent has rendered HTML page 

Also you might find interesting new feature ViewCells, it works same way: https://codeigniter4.github.io/userguide/outgoing/view_cells.html