![]() |
|
Snippets |
|
In order to delay a page redirect with several seconds, I wrote this simple helper
<?php use_helper('Javascript'); /** * 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) { sfContext::getInstance()->getResponse()->addJavascript(sfConfig::get('sf_prototype_web_dir').'/js/prototype'); $code = 'new PeriodicalExecuter(function() { location.href=\''.url_for($internal_uri).'\';}, '.$time.')'; return javascript_tag($code); }
See http://www.symfony-project.com/book/1_0/07-Inside-the-View-Layer#Adding%20Your%20Own%20Helpers for information on how to add your own helper