Jump to content

How to render part of a view before all the controller code ends.


itaym02

Recommended Posts

The scenario: A "forgot my password" for is filled with email.

On submission email is sent to the user. Due to the way ZF is working, the email is sent in the controller, before anything is thrown to the browser.

This makes it look like after the submission the site is stuck (if it takes a long time to send the email).

Is there a way to echo a message to the screen, on the lines "Your request is being taken care of...".

 

I can use AJAX to submit this request,

I can use cron to send the emails at a later time...

 

But I was wondering if there is a good way to do it built in ZF?

AFAIK the built-in compontents do not give you such a possibility, but you can extend it. Write your own response class with the outputBody() method overloaded:

 

public function outputBody()
{
    parent::outputBody();
    flush();
}

 

Once you set it, outputBody() will be flushing the data to the browser and then you'll have to prepare the views and rendering them in the controller.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.