Saturday, November 27, 2010

Re: Intercept HTML in afterFilter

Why not simply change the view--or the data--in the controller method?

On Sat, Nov 27, 2010 at 5:02 PM, puk <pallsopp@gmail.com> wrote:
> OK, it seems my assumption was correct.
>
> If you create a view helper with the following code, modify as you
> need:
>
> <?php
>        class WrapperHelper extends AppHelper {
>
>                public function afterRender() {
>                        $post = ob_get_contents();
>                        echo $post;
>                        exit;
>                }
>        }
> ?>
>
> You will see that what gets output is the view content. At that point
> you should be able to do an ob_end_clean() to clear the output buffer,
> do your search/replace on $post, then do ob_start() and echo the
> modified $post back to the buffer.
>
> When you include the helper, it might pay to ensure it is first in the
> helpers array of your controller, or better still create a custom
> AppController and add it is there with the default helpers.
>
> Hope that helps.
>
> Puk!
>
>
> On Nov 26, 4:53 pm, vg <vinay.gidwa...@gmail.com> wrote:
>> Is it possible to intercept the HTML in afterFilter (or any other
>> routine) so that after the view is rendered, you can do a search
>> +replace on something?
>
> Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions.
>
> You received this message because you are subscribed to the Google Groups "CakePHP" group.
> To post to this group, send email to cake-php@googlegroups.com
> To unsubscribe from this group, send email to
> cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
>

Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions.

You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en

No comments: