RealURL: Remove Controller and Action from URL

后端 未结 2 743
悲&欢浪女
悲&欢浪女 2020-12-06 19:00

I have an extension with a list and show action. Currently this extension can appear on multiple pages:

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

I have co

2条回答
  •  一个人的身影
    2020-12-06 19:30

    You can't avoid adding all the stuff when using f:link.action VH, instead you need to use f:link.page and pass only required params, sample:

    show article
    

    it will generate url like

    /current/page/?article=123
    

    or

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

    next in your first action of plugin (probably list) you just need to forward request to show action if given param exists:

    public function listAction() {
        if (intval(\TYPO3\CMS\Core\Utility\GeneralUtility::_GET('article'))>0) $this->forward('show');
    
        // Rest of code for list action...
    }
    

    and probably change signature of 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...
    }
    

提交回复
热议问题