我在扩展程序中创建了一个后端按钮,如下所示:
class ButtonBarHook {
public function getButtons(array $params, ButtonBar $buttonBar) {
$buttons = $params['buttons'];
$iconFactory = GeneralUtility::makeInstance(IconFactory::class);
$playController = new PlayController();
$button = $buttonBar->makeLinkButton();
$button->setIcon($iconFactory->getIcon('actions-document-export-csv', Icon::SIZE_SMALL));
$button->setTitle('Export als XML');
$button->setHref(***Link to my function***);
$buttons[ButtonBar::BUTTON_POSITION_LEFT][1][] = $button;
return $buttons;
}
}
到目前为止一切顺利。它出现在TYPO3的后端。现在我想链接按钮来调用我在不同类中编写的 php 函数。我已经尝试过 $button->setOnClick()
但这只会创建一个 javascript onClick 事件。
我认为 $button->setHref()
是更好的方法,但我不知道在这里放什么。
如何链接到我的 php 函数/操作?
最佳答案
)
您必须链接到您已注册的模块或ajax路由
https://docs.typo3.org/typo3cms/InsideTypo3Reference/CoreArchitecture/Backend/Routing/Index.html
然后您可以使用方法BackendUtility::getModuleUrl
方法获取要插入到setHref
的路径
关于php - TYPO3后端按钮调用php函数/操作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47809486/