2014-10-01 4 views
7

목록이있는 확장자가 있으며 작업을 표시합니다. 내가 그렇게 realurl를 구성RealURL : URL에서 컨트롤러 및 작업 제거

/page-1/ 
/page-2/subpage/ 

:

$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['realurl']=array (
    'encodeSpURL_postProc' => array('user_encodeSpURL_postProc'), 
    'decodeSpURL_preProc' => array('user_decodeSpURL_preProc'), 
    '_DEFAULT' => array (
     … 
     'postVarSets' => array(
      '_DEFAULT' => array(
       'controller' => array(
        array(
         'GETvar' => 'tx_extension_plugin[controller]', 
         'noMatch' => 'bypass', 
        ), 
       ), 
       'extension' => array(
        array(
         'GETvar' => 'tx_extension_plugin[action]', 
        ), 
        array(
         'GETvar' => 'tx_extension_plugin[controller]', 
        ), 
        array(
         'GETvar' => 'tx_extension_plugin[value]', 
         'lookUpTable' => array(
          'table' => 'table', 
          'id_field' => 'uid', 
          'alias_field' => 'name', 
          'addWhereClause' => ' AND NOT deleted AND NOT hidden', 
          … 
); 

function user_decodeSpURL_preProc(&$params, &$ref) { 
    $params['URL'] = str_replace('page-1/', 'page-1/extension/', $params['URL']); 
} 

function user_encodeSpURL_postProc(&$params, &$ref) { 
    $params['URL'] = str_replace('page-1/extension/', 'page-1/', $params['URL']); 
} 

가 지금과 같은 URL을 얻을 :

/page-1/ /* shows list */ 
/page-1/Action/show/name-of-single-element /* single view */ 

은 내가 실제로 원하는 것은 이것이다 현재이 확장은 여러 페이지에 나타날 수 있습니다 :

/page-1/name-of-single-element /* single view */ 

액션과 컨트롤러를 제거하려면 어떻게해야합니까?

나는 제거하는 경우 :

array('GETvar' => 'tx_extension_plugin[action]'), 
array('GETvar' => 'tx_extension_plugin[controller]'), 

가이 URL에 매개 변수를 추가합니다.

+0

와 함께이 구성을 사용, 그것은 당신의 확장? 코드를 바꿀 수 있습니까? 당신은 어떻게 당신의 링크/URL을 만들 수 있습니까? – biesior

+0

@biesior 예, 그것은 제 자신의 확장이고 네, 모든 것을 바꿀 수 있습니다. 링크는 다음과 같이 구성됩니다 : 기사보기' – lampshade

답변

5
, 대신 당신이 f:link.page를 사용에만 필요 PARAMS, 샘플 전달해야 당신은 f:link.action VH를 사용할 때 모든 물건을 추가하는 피할 수없는

:

<f:link.page additionalParams="{article : article.uid}" class="more" title="{article.name}">show article</f:link.page> 

가 생성 URL을

/current/page/?article=123 

등이

또는

/current/page/we-added-realurl-support-for-article 

첫 번째 플러그인 작업 URIbuilder 당신은 또한 구성을 사용할 수 있습니다 사용하는 경우 변경 아마 show

public function showAction() { 

    $article = $this->articleRepository->findByUid(intval(\TYPO3\CMS\Core\Utility\GeneralUtility::_GET('article'))); 

    if ($article == null) { 
     $this->redirectToUri($this->uriBuilder->reset()->setTargetPageUid($GLOBALS['TSFE']->id)->build()); 
    } 


    // Rest of code for show action... 
} 
+1

+1 - 매력처럼 작동합니다. 고마워. 좀 더 다목적으로 만들기 위해 코드를 약간 변경했습니다. 서명을'public function showAction (\ namespace $ article = null)'으로 변경하고 새로 추가 된 부분을'if (! $ article) {...}'에 래핑했습니다. – lampshade

+0

내 확장 기능에서 @transient 속성을 사용하고 있습니다 (http://stackoverflow.com/questions/27274477/parse-an-existing-json-string-in-fluid-template 참조). 위의 방법?내가 작동 시켰을 때 "일시적인"모든 데이터가 더 이상 출력되지 않았다. – Urs

+0

"동작"링크를 사용할 때 extbase가 속성의 유형에 대해 덜 엄격하게 여겼다. "일시적"과 아무 관련이 없습니다. – Urs

3

의 서명을

public function listAction() { 
    if (intval(\TYPO3\CMS\Core\Utility\GeneralUtility::_GET('article'))>0) $this->forward('show'); 

    // Rest of code for list action... 
} 

을하고 (아마 list) 당신은 주어진 PARAM이있는 경우 show 행동에 요청을 전달해야합니다

features.skipDefaultArguments = 1 

;

# if enabled, default controller and/or action is skipped when creating URIs through the URI Builder 
plugin.tx_extension.features.skipDefaultArguments = 1 

내가 realurl 바이 패스 그것은 또 다른 접근 방식이 필요

'postVarSets' => array(
    '_DEFAULT' => array(
    'extbaseParameters' => array(
     array(
     'GETvar' => 'tx_extension_plugin[action]', 
     'noMatch' => 'bypass', 
    ), 
    ), 
), 
),