Welcome Guest, Not a member yet? Register   Sign In
Using Controller Filters to add data to Views
#1

Hi,

I read about Controller Filters but still unsure how to send data to Views using AFTER filter as per documentation AFTER Filter "Allows to inspect and modify the response"

In controllers we can send data to views using  "return view('My_view', $this->data);" 
How do we send or iterate through the response object using After Filters? Can we send data to views as well?

Regards
Reply
#2

Filters are for Controllers not views. What you want to look at is View Cells.
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply
#3

(08-04-2020, 03:59 AM)InsiteFX Wrote: Filters are for Controllers not views. What you want to look at is View Cells.

Documentation says about AFTER filters: "This does allow you to modify the final output, or simply do something with the final output."

How to access the response object & do something for example: remove bad words & include a view cell?
Reply
#4

What you get are a Response object, and you can do everything that's available here:
https://codeigniter.com/user_guide/outgo...ponse.html

And for bad words:
$response->getBody();
// do stuff
$response->setBody($clean);

Don't think you can inject a view cell somewhere. Haven't tested it thought.
Reply




Theme © iAndrew 2016 - Forum software by © MyBB