我已经构建了一个扩展,我正在使用 Typoscript 引导并将其放置在模态框中。我在 Page 元素中也包含相同的扩展名,但操作不同。
问题是当从页面中的扩展调用其他操作时,它还反映了模式框中引导版本中显示的内容。我想要做的是无论 URL 中有什么参数(告诉扩展程序要执行什么操作),模式框中的参数总是首先调用相同的操作。
这可能吗?
我应该为我的问题寻找不同的解决方案吗?
我已经构建了一个扩展,我正在使用 Typoscript 引导并将其放置在模态框中。我在 Page 元素中也包含相同的扩展名,但操作不同。
问题是当从页面中的扩展调用其他操作时,它还反映了模式框中引导版本中显示的内容。我想要做的是无论 URL 中有什么参数(告诉扩展程序要执行什么操作),模式框中的参数总是首先调用相同的操作。
这可能吗?
我应该为我的问题寻找不同的解决方案吗?
在我看来,最简单的方法是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 传输不同的操作,它只会影响第一个或第二个控制器。
不要忘记:
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' => '',
)
);