2013-07-30 81 views

回答

7

您可以使用此行:

$this->uriBuilder->getRequest()->getRequestUri() 

例子:

public function newAction(Tx_YourExtension_Domain_Model_YourModel $yourModel = NULL) { 
    $this->view->assign('yourModel', $yourModel); 
    $this->view->assign('url', $this->uriBuilder->getRequest()->getRequestUri()); 
} 
5

雖然下面是更有效的..

$this->controllerContext 
    ->getUriBuilder() 
    ->reset() 
    ->setTargetPageUid(int PAGE_UID) 
    ->setArguments(array ARRAY_VARIABLE_OF_ADDITIONAL_ARGUMENTS) 
    ->buildFrontendUri(); 

OR

包括UriBuilder對象

/** 
* UriBuilder 
* 
* @var \TYPO3\CMS\Extbase\Mvc\Web\Routing\UriBuilder 
* @inject 
*/ 
protected $uriBuilder = NULL; 

獲取URL使用以下

$this->uriBuilder 
    ->reset() 
    ->setTargetPageUid(int PAGE_UID) 
    ->setArguments(array ARRAY_VARIABLE_OF_ADDITIONAL_ARGUMENTS) 
    ->buildFrontendUri(); 

對於基URI

$this->request->getBaseUri() 
    OR 
$GLOBALS['TSFE']->baseUrl 
+0

這一個對我幫助很大。!謝謝Mihir –

+0

我不明白這是如何更有效率。 – j4k3

相關問題