0

我已经构建了一个扩展,我正在使用 Typoscript 引导并将其放置在模态框中。我在 Page 元素中也包含相同的扩展名,但操作不同。

问题是当从页面中的扩展调用其他操作时,它还反映了模式框中引导版本中显示的内容。我想要做的是无论 URL 中有什么参数(告诉扩展程序要执行什么操作),模式框中的参数总是首先调用相同的操作。

这可能吗?

我应该为我的问题寻找不同的解决方案吗?

4

2 回答 2

1

在我看来,最简单的方法是AbstractContoller继承两个不同的控制器。

这样,它们将完全分离,但可以共享相同的操作:

namespace YOUR\Extension\Controller;
abstract class AbstractController extends \TYPO3\CMS\Extbase\Mvc\Controller\ActionController{

    public function firstAction(){
        // your code here
    }

    public function secondAction(){
        // your code here
    }
}

第一控制器:

namespace YOUR\Extension\Controller;
class FirstController extends AbstractController{
    //no need to add actions here
}

第二控制器:

namespace YOUR\Extension\Controller;
class SecondController extends AbstractController{
    //no need to add actions here
}

然后,您在页面上包含的打字稿会调用FirstController->firstAction,模式中的打字稿会调用SecondController->firstAction。如果您通过 GET 传输不同的操作,它只会影响第一个或第二个控制器。

不要忘记:

  • 在 ext_localconf.php 中注册控制器/操作
  • 相应地复制/移动模板(它们需要位于以控制器命名的文件夹中,例如模板/first/)
于 2014-11-05T13:20:55.463 回答
0

Do you call both of your Controller/Action sets in one Plugin? I would try to split them fe like this

\TYPO3\CMS\Extbase\Utility\ExtensionUtility::configurePlugin(
    'VENDOR.' . $_EXTKEY,
    'Pluginkey1',
    array(
        'FirstController' => 'foo, bar',
    ),
    // non-cacheable actions
    array(
        'FirstController' => '',
    )
);

\TYPO3\CMS\Extbase\Utility\ExtensionUtility::configurePlugin(
    'VENDOR.' . $_EXTKEY,
    'Pluginkey2',
    array(
        'SecondController' => 'baz',
    ),
    // non-cacheable actions
    array(
        'SecondController' => '',   
    )
);
于 2014-11-21T00:50:46.573 回答