1

例如,我有一个引用 URL。我想根据上一页的模块重定向到一个页面。

4

1 回答 1

2

此页面上有一个代码片段。要获取上一页的模块和操作,您将使用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'];
于 2012-05-20T10:34:16.830 回答