Setting a Zend Framework _redirect Referer

submit to reddit

Seems to be impossible, just because the only parameters you can set are far less than setting a referrer. Thus you’ve to rely on your browser capabilities. However the most reliable way is to redirect with referrer in mind. Something like _GET parameters.

$this->_redirect('/url/return-to/1');

Once this parameter is processed by the controller/action you can return to the referrer!

Related posts:

  1. Redirecting with Zend Framework
  2. Zend Framework – Disable Zend Layout
  3. Zend Examples: GET Parameters Default Value

You are a GREAT developer? Click here to answer the weekly quiz!

This entry was posted in micro tutorial, PHP, zend framework and tagged , , , , , , , . Bookmark the permalink.

2 Responses to Setting a Zend Framework _redirect Referer

  1. PhpZend says:

    other ways to do

    //example 1
    $this->_helper->getHelper(‘Redirector’)->gotoSimple(‘action’, ‘controller’, ‘module’, array(‘param1′ => $value1, ‘param2′=>$value2));

    //example 2
    return $this->_forward(‘action’,'controller’,'module’, array(‘param1′=>$param1));

  2. PhpZend says:

    i forgot,
    //example 3

    in your view send:
    $backurl = urlencode($this->Url());

    in your action:
    $this->_helper->getHelper(‘Redirector’)->gotoUrl(urldecode($backurl))

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre lang="" line="" escaped="" highlight="">