Typo3 类型3 Extbase switchableControllerActions
我有自己的扩展,它的控制器有两个动作:listAction和showAction。Typo3 类型3 Extbase switchableControllerActions,typo3,fluid,extbase,Typo3,Fluid,Extbase,我有自己的扩展,它的控制器有两个动作:listAction和showAction。 问题:我可以在同一页上显示两个操作吗 在特定页面,我用自己的插件创建了一个插入插件记录,在插件后端配置的flexform中,我通过switchableControllerActions字段选择了“列表操作”。列表操作包含产品列表,其中包含指向产品显示操作的链接 那我想要什么呢 F.e。 我有网页产品。URL是example.com/products(这是我的列表操作) 对于show action,我需要类似exa
问题:我可以在同一页上显示两个操作吗 在特定页面,我用自己的插件创建了一个插入插件记录,在插件后端配置的flexform中,我通过switchableControllerActions字段选择了“列表操作”。列表操作包含产品列表,其中包含指向产品显示操作的链接 那我想要什么呢 F.e。 我有网页产品。URL是example.com/products(这是我的列表操作)
对于show action,我需要类似example.com/products/name of product的URL 我找到了一个具有此功能的扩展。是的。我注意到在插件flexform的switchableControllerActions字段中有如下内容:
<switchableControllerActions>
<TCEforms>
<label>LLL:EXT:gb_events/Resources/Private/Language/locallang_db.xlf:flexform.default.switchableControllerActions</label>
<config>
<type>select</type>
<items type="array">
<numIndex index="0" type="array">
<numIndex index="0">LLL:EXT:gb_events/Resources/Private/Language/locallang_db.xlf:flexform.default.switchableControllerActions.upcoming</numIndex>
<numIndex index="1">Event->upcoming;Event->list;Event->calendar;Event->show;Event->export</numIndex>
</numIndex>
<numIndex index="1" type="array">
<numIndex index="0">LLL:EXT:gb_events/Resources/Private/Language/locallang_db.xlf:flexform.default.switchableControllerActions.list</numIndex>
<numIndex index="1">Event->list;Event->upcoming;Event->calendar;Event->show;Event->export</numIndex>
</numIndex>
<numIndex index="2" type="array">
<numIndex index="0">LLL:EXT:gb_events/Resources/Private/Language/locallang_db.xlf:flexform.default.switchableControllerActions.calendar</numIndex>
<numIndex index="1">Event->calendar;Event->upcoming;Event->list;Event->show;Event->export</numIndex>
</numIndex>
<numIndex index="3" type="array">
<numIndex index="0">LLL:EXT:gb_events/Resources/Private/Language/locallang_db.xlf:flexform.default.switchableControllerActions.details</numIndex>
<numIndex index="1">Event->show;Event->list;Event->upcoming;Event->calendar;Event->export</numIndex>
</numIndex>
</items>
<maxitems>1</maxitems>
<size>1</size>
</config>
<onChange>reload</onChange>
</TCEforms>
</switchableControllerActions>
LLL:EXT:gb_events/Resources/Private/Language/locallang_db.xlf:flexform.default.switchableControllerActions
选择
LLL:EXT:gb_events/Resources/Private/Language/locallang_db.xlf:flexform.default.switchableControllerActions.com
活动->即将举行;事件->列表;事件->日历;活动->展示;事件->导出
LLL:EXT:gb_events/Resources/Private/Language/locallang_db.xlf:flexform.default.switchableControllerActions.list
事件->列表;活动->即将举行;事件->日历;活动->展示;事件->导出
LLL:EXT:gb_events/Resources/Private/Language/locallang_db.xlf:flexform.default.switchableControllerActions.calendar
事件->日历;活动->即将举行;事件->列表;活动->展示;事件->导出
LLL:EXT:gb_events/Resources/Private/Language/locallang_db.xlf:flexform.default.switchableControllerActions.details
活动->展示;事件->列表;活动->即将举行;事件->日历;事件->导出
1.
1.
重新加载
我已经更新了我的flexform配置。但它仍然不起作用。当我点击带有ShowAction的链接后,我有了相同的列表视图
提前谢谢。我将非常感谢您的帮助。请确保您的
switchableControllerActions
中同时包含列表和详细操作,如下所示:
<numIndex index="0" type="array">
<numIndex index="0">LLL:EXT:gb_events/Resources/Private/Language/locallang_db.xlf:flexform.default.switchableControllerActions.upcoming</numIndex>
<numIndex index="1">Event->list;Event->calendar;Event->show</numIndex>
</numIndex>
要从RealUrl中的URL中获取其他控制器参数,请使用以下内容:
array(
'GETvar' => 'tx_extkey_plugin[action]',
'noMatch' => 'bypass'
),
你可以在这篇德国文章中找到更多关于这个技巧的信息。从结构上来说,更合理的方法是将这种逻辑保留在控制器中 将showAction设置为defaut,并检查其初始化中的参数。如果未提供任何产品,或无法加载指定的产品,请转至列表操作
/**
* initialize action show
* @return void
*/
public function initializeShowAction() {
if($this->request->hasArgument('product')){
if( $product=$this->stadtRepository->findByUid(
intval($this->request->getArgument('product'))
) ){
$this->request->setArgument('product',$product);
return;
}
}
$this->forward('list');
}
谢谢你的回答。按照你在这里描述的那样做是个好主意:)如果我有足够的声誉,我会呕吐。
/**
* initialize action show
* @return void
*/
public function initializeShowAction() {
if($this->request->hasArgument('product')){
if( $product=$this->stadtRepository->findByUid(
intval($this->request->getArgument('product'))
) ){
$this->request->setArgument('product',$product);
return;
}
}
$this->forward('list');
}