【发布时间】:2014-08-08 07:15:45
【问题描述】:
谁能告诉我,在 Typo3 的后端添加自己的按钮的方法是什么?它应该出现在那里:
提前谢谢!!
【问题讨论】:
标签: typo3 typo3-6.1.x
谁能告诉我,在 Typo3 的后端添加自己的按钮的方法是什么?它应该出现在那里:
提前谢谢!!
【问题讨论】:
标签: typo3 typo3-6.1.x
TYPO3 6.2: 使用文件 .../typo3_src-6.2.4/typo3/sysext/backend/Classes/Controller/BackendController.php 及其方法 addToolbarItem。
/**
* Adds an item to the toolbar, the class file for the toolbar item must be loaded at this point
*
* @param string $toolbarItemName Toolbar item name, f.e. tx_toolbarExtension_coolItem
* @param string $toolbarItemClassName Toolbar item class name, f.e. tx_toolbarExtension_coolItem
* @return void
* @throws \UnexpectedValueException
*/
public function addToolbarItem($toolbarItemName, $toolbarItemClassName) {
$toolbarItem = GeneralUtility::makeInstance($toolbarItemClassName, $this);
if (!$toolbarItem instanceof \TYPO3\CMS\Backend\Toolbar\ToolbarItemHookInterface) {
throw new \UnexpectedValueException('$toolbarItem "' . $toolbarItemName . '" must implement interface TYPO3\\CMS\\Backend\\Toolbar\\ToolbarItemHookInterface', 1195125501);
}
if ($toolbarItem->checkAccess()) {
$this->toolbarItems[$toolbarItemName] = $toolbarItem;
} else {
unset($toolbarItem);
}
}
使用与 opendocs 系统扩展相同的方式。
if (TYPO3_MODE === 'BE') {
// Now register the class as toolbar item
$GLOBALS['TYPO3backend']->addToolbarItem('opendocs', 'TYPO3\\CMS\\Opendocs\\Controller\\OpendocsController');
}
查看文件.../typo3_src-6.2.4/typo3/sysext/opendocs/Classes/Controller/OpendocsController.php:
class OpendocsController implements \TYPO3\CMS\Backend\Toolbar\ToolbarItemHookInterface {
【讨论】: