Reputation: 1043
For example, I have a referer URL. I want to redirect to a page according to the previous page's module.
Upvotes: 1
Views: 1212
Reputation: 2333
There is a code snippet on this page. To get module and action of the previous page, you will use the referer:
$referer = sfContext::getInstance()->getRequest()->getReferer();
// you have to check if the referer is not empty and is a page of your site
....
// then get the module and action:
$url = parse_url($referer);
$path = trim($url['path'], '/');
if (!sfConfig::get('sf_no_script_name') && $pos = strpos($path, '/') )
{
$path = substr($path, $pos+1);
}
$params = sfContext::getInstance()->getRouting()->findRoute('/'.$path);
$module = $params['parameters']['module'];
$action = $params['parameters']['action'];
Upvotes: 2