First of all we extend the database table pages with file ext_tables.sql:
CREATE TABLE pages
(
toolbar_note varchar(255) DEFAULT '' NOT NULL,
toolbar_active tinyint(4) unsigned DEFAULT '0' NOT NULL,
toolbar_disable tinyint(4) unsigned DEFAULT '0' NOT NULL,
toolbar_note_empty_fields varchar(255) DEFAULT '' NOT NULL,
toolbar_phonecall_number varchar(255) DEFAULT '' NOT NULL,
toolbar_phonecall_openingtime varchar(255) DEFAULT '' NOT NULL,
toolbar_address_street varchar(255) DEFAULT '' NOT NULL,
toolbar_address_city varchar(255) DEFAULT '' NOT NULL,
toolbar_logo int(11) unsigned DEFAULT '0',
);
The whole thing has to be defined in TCA Configuration/TCA/Overrides/pages.php so that you can edit these fields in the backend:
<?php
defined('TYPO3_MODE') || die('Access denied.');
$llPrefix = 'LLL:EXT:in2template/Resources/Private/Language/backend.xlf:';
$llPrefixFrontend = 'LLL:EXT:frontend/Resources/Private/Language/locallang_ttc.xlf:';
$columns = [
'toolbar_note' => [
'exclude' => true,
'displayCond' => 'FIELD:toolbar_active:=:0',
'config' => [
'type' => 'user',
'userFunc' => 'In2code\In2template\Tca\ToolbarNote->render'
],
],
'toolbar_active' => [
'exclude' => true,
'onChange' => 'reload',
'label' => $llPrefix . 'TCA.pages.toolbar_active',
'config' => [
'type' => 'check',
],
],
'toolbar_disable' => [
'exclude' => true,
'displayCond' => 'FIELD:toolbar_active:=:1',
'onChange' => 'reload',
'label' => $llPrefix . 'TCA.pages.toolbar_disable',
'config' => [
'type' => 'check',
],
],
'toolbar_note_empty_fields' => [
'exclude' => true,
'displayCond' => [
'AND' => [
'FIELD:toolbar_active:=:1',
'FIELD:toolbar_disable:=:0'
]
],
'config' => [
'type' => 'user',
'userFunc' => 'In2code\In2template\Tca\ToolbarNoteEmptyFields->render'
],
],
'toolbar_phonecall_number' => [
'exclude' => true,
'displayCond' => [
'AND' => [
'FIELD:toolbar_active:=:1',
'FIELD:toolbar_disable:=:0'
]
],
'label' => $llPrefix . 'TCA.pages.toolbar_phonecall_number',
'config' => [
'type' => 'input',
'size' => 30,
'eval' => 'trim',
'default' => ''
],
],
'toolbar_phonecall_openingtime' => [
'exclude' => true,
'displayCond' => [
'AND' => [
'FIELD:toolbar_active:=:1',
'FIELD:toolbar_disable:=:0'
]
],
'label' => $llPrefix . 'TCA.pages.toolbar_phonecall_openingtime',
'config' => [
'type' => 'input',
'size' => 30,
'eval' => 'trim',
'default' => ''
],
],
'toolbar_address_street' => [
'exclude' => true,
'displayCond' => [
'AND' => [
'FIELD:toolbar_active:=:1',
'FIELD:toolbar_disable:=:0'
]
],
'label' => $llPrefix . 'TCA.pages.toolbar_address_street',
'config' => [
'type' => 'input',
'size' => 30,
'eval' => 'trim',
'default' => ''
],
],
'toolbar_address_city' => [
'exclude' => true,
'displayCond' => [
'AND' => [
'FIELD:toolbar_active:=:1',
'FIELD:toolbar_disable:=:0'
]
],
'label' => $llPrefix . 'TCA.pages.toolbar_address_city',
'config' => [
'type' => 'input',
'size' => 30,
'eval' => 'trim',
'default' => ''
],
],
'toolbar_logo' => [
'exclude' => true,
'label' => $llPrefix . 'TCA.pages.toolbar_logo',
'displayCond' => [
'AND' => [
'FIELD:toolbar_active:=:1',
'FIELD:toolbar_disable:=:0'
]
],
'config' => \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::getFileFieldTCAConfig(
'toolbar_logo',
[
'appearance' => [
'createNewRelationLinkTitle' => $llPrefixFrontend . 'images.addFileReference'
],
'maxitems' => 1,
],
$GLOBALS['TYPO3_CONF_VARS']['GFX']['imagefile_ext']
)
],
];
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addTCAcolumns('pages', $columns);
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addToAllTCAtypes(
'pages',
'--div--;' . $llPrefix . 'TCA.pages.tab_toolbar, toolbar_note, '
. '--palette--;' . $llPrefix . 'TCA.pages.palette_toolbar_activate; palette_toolbar_activate, '
. 'toolbar_logo,'
. '--palette--;' . $llPrefix . 'TCA.pages.palette_toolbar_phone; palette_toolbar_phone, '
. '--palette--;' . $llPrefix . 'TCA.pages.palette_toolbar_address; palette_toolbar_address,'
);
$GLOBALS['TCA']['pages']['palettes']['palette_toolbar_activate'] = [
'showitem' => 'toolbar_active, toolbar_disable, --linebreak--, toolbar_note_empty_fields, '
];
$GLOBALS['TCA']['pages']['palettes']['palette_toolbar_phone'] = [
'showitem' => 'toolbar_phonecall_number, toolbar_phonecall_openingtime, --linebreak--, toolbar_phonecall_link'
];
$GLOBALS['TCA']['pages']['palettes']['palette_toolbar_address'] = [
'showitem' => 'toolbar_address_street, toolbar_address_city'
];