Create new Page Type
The following example adds a new page type called "Archive".
Changes need to be made in several files to create a new page type. Follow the directions below to the end:
Changed in version 12.0
A new Page
was introduced replacing the
$GLOBALS
array. Use the version selector to look up
the syntax in the corresponding documentation version for older TYPO3 versions.
The first step is to add the new page type to the
\TYPO3\
. Then you need to add
the icon chosen for the new page type and allow users to drag and drop the new
page type to the page tree.
The new page type is added to the Page
in
ext_
:
<?php
use TYPO3\CMS\Core\DataHandling\PageDoktypeRegistry;
use TYPO3\CMS\Core\Utility\GeneralUtility;
defined('TYPO3') or die();
// Define a new doktype
$customPageDoktype = 116;
// Add page type to system
$dokTypeRegistry = GeneralUtility::makeInstance(PageDoktypeRegistry::class);
$dokTypeRegistry->add(
$customPageDoktype,
[
'allowedTables' => '*',
],
);
We need to add the following user TSconfig to all users, so that the new page type is displayed in the wizard:
You can load the file like this:
<?php
use TYPO3\CMS\Core\Utility\ExtensionManagementUtility;
defined('TYPO3') or die();
// Add custom doktype to the page tree toolbar
ExtensionManagementUtility::addUserTSConfig(
"@import 'EXT:examples/Configuration/TsConfig/User/*.tsconfig'",
);
The icon is registered in Configuration/
:
<?php
use TYPO3\CMS\Core\Imaging\IconProvider\SvgIconProvider;
return [
'tx-examples-archive-page' => [
'provider' => SvgIconProvider::class,
'source' => 'EXT:examples/Resources/Public/Images/ArchivePage.svg',
],
];
Furthermore we need to modify the configuration of page records. As one can modify the pages, we
need to add the new doktype as an select option and associate it with the configured icon. That is done in
Configuration/
:
<?php
defined('TYPO3') or die();
// encapsulate all locally defined variables
(function () {
// SAME as registered in ext_tables.php
$customPageDoktype = 116;
$customIconClass = 'tx-examples-archive-page';
// Add the new doktype to the page type selector
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addTcaSelectItem(
'pages',
'doktype',
[
'label' => 'LLL:EXT:examples/Resources/Private/Language/locallang.xlf:archive_page_type',
'value' => $customPageDoktype,
'icon' => $customIconClass,
'group' => 'special',
],
);
// Add the icon to the icon class configuration
$GLOBALS['TCA']['pages']['ctrl']['typeicon_classes'][$customPageDoktype] = $customIconClass;
})();
As you can see from the example, to make sure you get the correct icons,
you can utilize typeicon_
.
It is possible to define additional type icons for special case pages:
- Page contains content from another page
<doktype>-
, For example:content From Pid $GLOBALS
.['TCA'] ['pages'] ['ctrl'] ['typeicon_ classes'] ['116- content From Pid'] - Page is hidden in navigation
<doktype>-
For example:hideinmenu $GLOBALS
.['TCA'] ['pages'] ['ctrl'] ['typeicon_ classes'] ['116- hideinmenu'] - Page is the root of the site
<doktype>-
For example:root $GLOBALS
.['TCA'] ['pages'] ['ctrl'] ['typeicon_ classes'] ['116- root']
Note
Make sure to add the additional icons using the Icon API!