Modify HTML output from block

Permalink
Is there a way a block can intercept and modify the output of the page where it is placed? I know it could be made client-side with javascript, but I would rather prefer to do it server side with PHP so that it could benefit from the page caching.
I have been trying with php output buffering with no luck.
Any idea?

 
JohntheFish replied on at Permalink Best Answer Reply
JohntheFish
You won't be able to do it in php from within a block, but you could do it from concrete5 event handlers. Start buffering in a before render handler, then close buffering in a render complete handler and then process the captured output. It would involve catching most of the page, not just your area.

(I think this may be how some of the email scrambling addons do it - have not looked inside them for a long time, so cant be sure)

Another way to do it would be to modify the area output section of a theme to catch the area content and then process it before outputting.
hemam replied on at Permalink Reply
Many thanks for your reply, JohntheFish!
If that cannot be made for given pages, but using a handler (for what I have seen so far that means every page in the site) then it will be maybe too much overload, so I will finally use the client side solution.
However, I will take a deeper look at that mechanism since it seems it can have a bunch of interesting uses.
JohntheFish replied on at Permalink Reply
JohntheFish
If you are looking at events, I recommend Mnkras's event tester addon. Its great for learning as well as testing.