Jump to content

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


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.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.