Reputation: 207
I've created a backend button in my extension which looks like this:
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;
}
}
So far so good. It appears in the backend of TYPO3. Now I want to link the button to call a php function I wrote in a different class. I already tried $button->setOnClick()
but this only creates a javascript onClick event.
I think $button->setHref()
is the better approach but I don't know what to put in here.
How can I link to my php function/action?
Upvotes: 2
Views: 909
Reputation: 522
)
You have to link to a module or ajax route, that you have registered
https://docs.typo3.org/typo3cms/InsideTypo3Reference/CoreArchitecture/Backend/Routing/Index.html
And then you can use the method BackendUtility::getModuleUrl
method to get a path to insert into setHref
Upvotes: 2