I’d like to manipulate the DOM included in the view using a server side library (PHP Simple HTML DOM Parser for instance) but I do not know how to manipulate (server side) the DOM of a view before being output to the browser.
I’ve tried the PHP Output Buffer functions but it seems that Yii uses it extensively and when I try to use ob_start() Yii must have other ob_start in the code that is flushed and printed to the browser and does the same with mine.
I’ve found a way to do it. The render method allows to pass an argument that allows to override the default echo of the view output and store it on a variable that can be manipulated.
The only downside is that every rendered view includes in its output the layout rendering as well, so I have to find way of not wasting resources by parsing the layout in every view that is output to the presentation layer.
I have to think a bit about it and if, or when , I find an acceptable way(performance wise) of doing it, I’ll post it here.