Project

General

Profile

Actions

Feature #69814

closed

ModuleTemplate API

Added by Mathias Schreiber about 9 years ago. Updated about 7 years ago.

Status:
Closed
Priority:
Should have
Category:
Backend API
Target version:
Start date:
2015-09-15
Due date:
% Done:

100%

Estimated time:
PHP Version:
Tags:
Complexity:
Sprint Focus:
Remote Sprint

Description

Challenge

Currently all DocHeaders are implemented on their own.
This means we have about 80 DocHeaders which are equal but not the same.
The main challenge is to provide extension developers with all tools they need to build decent backend modules while maintaining control of the docHeader itself.

Solution

We will provide a replacement for DocumentTemplate which provides an easy-to-use API which is on the other hand flexible enough to tackle all tasks we currently think of.
At the same time we will remove the amount of duplicate marker based templates.

The API uses the Fluent-API approach and has been built to supply maximum IDE code completion support.

Parts of a docHeader

Currently a typical docHeader is split up into the following sections:
  • Top Bar
    • Context Sensitive Help Icon
    • Select Menu(s)
    • Path
    • RecordInformation incl. Clickmenu
  • Bottom Bar
    • Left Button Bar
    • Right Button Bar

API Components

Buttons

InputButton

Used to generate a <button> element.

LinkButton

Used to generate links

SplitButton

A mixed component accepting multiple button objects and renders them into a condensed form.

Examples of usages

Adding a button

$openInNewWindowButton = $this->moduleTemplate->getDocHeaderComponent()->getButtonBar()
    ->makeLinkButton()
    ->setHref('#')
    ->setTitle($this->getLanguageService()->sL('LLL:EXT:lang/locallang_core.xlf:labels.openInNewWindow', TRUE))
    ->setIcon($this->iconFactory->getIcon('actions-window-open', Icon::SIZE_SMALL))
    ->setOnClick(htmlspecialchars($aOnClick));
$this->moduleTemplate->getDocHeaderComponent()->getButtonBar()->addButton($openInNewWindowButton, ButtonBar::BUTTON_POSITION_RIGHT);

Adding a menu with menu items

$languageMenu = $this->moduleTemplate->getDocHeaderComponent()->getModuleMenuRegistry()->makeMenu()
    ->setIdentifier('_langSelector')
    ->setLabel($this->getLanguageService()->sL('LLL:EXT:lang/locallang_general.xlf:LGL.language', TRUE));
$menuItem = $languageMenu->makeMenuItem()
    ->setTitle($lang['title'] . $newTranslation)
    ->setHref($href);
if((int)$lang['uid'] === $currentLanguage) {
    $menuItem->setActive(TRUE);
}
$languageMenu->addMenuItem($menuItem);
$this->moduleTemplate->getDocHeaderComponent()->getModuleMenuRegistry()->addMenu($languageMenu);

Related issues 4 (0 open4 closed)

Related to TYPO3 Core - Epic #69841: Roll out of ModuleTemplate APIClosed2015-09-15

Actions
Related to TYPO3 Core - Bug #71386: Wrong title in rst fileClosedFrank Nägler2015-11-06

Actions
Precedes TYPO3 Core - Bug #70065: Cannot create bookmarkClosed2015-09-24

Actions
Precedes TYPO3 Core - Bug #70063: Invalid/missing CSRF tokenClosed2015-09-24

Actions
Actions

Also available in: Atom PDF