Code snippets for symfony 1.x

Navigation

Snippets tagged "generator redirect"

make a redirect to module/action of an other application

This snippet show :

* How to redirect to module/action of an other application

* An exemple of adding a view object action in admin generator


There is no method given by Symfony to redirect to module/action of an other application. Redirect method of SfActions permit only to redirect to module/action of the current application or to an url.

In the forum fabien say, it is because applications are independant.

But it could be usefull for a backend (generated with admin generator), to add a new "object_actions" which permit to view the result of a record (an article for e.g.) by redirecting to the article webpage in the frontend.

Then you can add in the Actions class an action method like :

public function executeView() {
  $this->redirect("http://".$this->getContext()->getRequest()->getHost().'/article/'.$this->getRequestParameter('id'));
}
 
// or if the application is not the default application (behind index.php) and the application is named "frontend"
 
public function executeView() {
  $applicationName='frontend';
  $this->redirect("http://".$this->getContext()->getRequest()->getHost().'/'.$applicationName.'.php/article/'.$this->getRequestParameter('id'));
}

To add this action in the backend, add this line to generator.yml :

generator:
  param:
    list:
      object_actions:
        _edit: -
        view:  { name : View this article, action: view, icon: backend/view.png }
by Sylvain PAPET on 2006-06-06, tagged generator  redirect 
(2 comments)