2012-05-20 60 views

回答

2

有一個this page的代碼片段。要獲取上一頁的模塊和動作,請使用引用者:

$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']; 
+0

救了我的命:D – JhovaniC

相關問題