【发布时间】:2012-05-27 03:58:03
【问题描述】:
例如,我有一个引用 URL。我想根据上一页的模块重定向到一个页面。
【问题讨论】:
例如,我有一个引用 URL。我想根据上一页的模块重定向到一个页面。
【问题讨论】:
this page 上有一个代码 sn-p。要获取上一页的模块和操作,您将使用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'];
【讨论】: