Welcome Guest, Not a member yet? Register   Sign In
How to get view as data in CI4 ?
#1

in CI3, I just have to add parameter like:
$page = $this->load->view('page',$data,true);
how i do this in CI4?, it seems the view function has been changed.
Reply
#2

The helper function `view()` simply returns a string. You can capture that however you like, and when you are ready you either echo it or return it from your Controller.
Reply
#3

(This post was last modified: 08-07-2021, 05:43 AM by munggaran.)

(08-07-2021, 04:43 AM)MGatner Wrote: The helper function `view()` simply returns a string. You can capture that however you like, and when you are ready you either echo it or return it from your Controller.

I've tried this:

$page = view('/parts/global/part_style', $this->data);

// the above line will return browser to show part_style instead just fetch into $page

return $page;

any suggestion?

solved.

it seems i have to remove setHeader before using View, just made another function then remove the header and Voila

$this->response->setHeader('Content-Type', 'text/css');
$this->response->noCache();
Reply




Theme © iAndrew 2016 - Forum software by © MyBB