Code snippets for symfony 1.x


Refine Tags

Snippets tagged "redirect"

Delayed javascript page redirect

In order to delay a page redirect with several seconds, I wrote this simple helper

   * Adds javascript code to delay a page redirect
   * @param string 'module/action' or '@rule' of the action (same argument as url_for())
   * @param int time of delay in seconds. Default = 5
   * @return JavaScript tag for delayed page redirect
  function delayed_redirect($internal_uri, $time = 5)
    $code = 'new PeriodicalExecuter(function() { location.href=\''.url_for($internal_uri).'\';}, '.$time.')';
    return javascript_tag($code);

See for information on how to add your own helper

by wtreur on 2007-10-04, tagged helper  javascript  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() {
// or if the application is not the default application (behind index.php) and the application is named "frontend"
public function executeView() {

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

        _edit: -
        view:  { name : View this article, action: view, icon: backend/view.png }
by Sylvain PAPET on 2006-06-06, tagged generator  redirect