Typo3 使用打字脚本引导扩展并调用特定操作

Typo3 使用打字脚本引导扩展并调用特定操作,typo3,typoscript,extbase,typo3-6.2.x,Typo3,Typoscript,Extbase,Typo3 6.2.x,我已经建立了一个扩展,我正在引导打字脚本,并把它放在一个模态框。我在页面元素中也包含了相同的扩展名,但使用了不同的操作 问题是,当从页面中的扩展调用其他操作时,它还反映了模式框中引导版本中显示的内容。我想做的是,不管URL中有什么参数(告诉扩展要执行什么操作),模态框中的参数总是首先调用相同的操作 这可能吗 我是否应该为我的问题寻找一个不同的解决方案?我认为最简单的方法是一个AbstractContoller,由两个不同的控制器继承 这样,系统将完全分离,但可以共享相同的操作: namespac

我已经建立了一个扩展,我正在引导打字脚本,并把它放在一个模态框。我在页面元素中也包含了相同的扩展名,但使用了不同的操作

问题是,当从页面中的扩展调用其他操作时,它还反映了模式框中引导版本中显示的内容。我想做的是,不管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
}
第二控制器:

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中注册控制器/操作
  • 相应地复制/移动模板(它们需要位于以控制器命名的文件夹中,例如templates/first/)

是否在一个插件中调用两个控制器/操作集? 我会像这样把他们分开

\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' => '',   
    )
);

这是解决我问题的正确方法。谢谢。我原以为这样做就可以了,但不幸的是,它做的事情和一个控制器有几个动作一样。GET中的所有内容都优先于我在引导扩展时设置的内容。如果GET调用不同的控制器,我会从嵌入式版本中得到一个异常,即不允许在那里使用它。可悲的是,这个问题还在继续。如果您有任何补充,我们将不胜感激。