Skip to content

Instantly share code, notes, and snippets.

@cedricziel
Created May 4, 2015 20:47
Show Gist options
  • Select an option

  • Save cedricziel/83a51482ed092365f0ae to your computer and use it in GitHub Desktop.

Select an option

Save cedricziel/83a51482ed092365f0ae to your computer and use it in GitHub Desktop.
Add a custom doktype to TYPO3 pages table
<?php
/**
* Custom Doktypes
*/
// Define a new doktype
$customShortlinkDoktype = 120;
$customPageIcon = \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extRelPath($_EXTKEY) . 'Resources/Public/Icons/Shortlink.png';
// Add the new doktype to the list of page types
$GLOBALS['PAGES_TYPES'][$customShortlinkDoktype] = array(
'type' => 'sys',
'icon' => $customPageIcon,
'allowedTables' => '*'
);
// Add the new doktype to the page type selector
$GLOBALS['TCA']['pages']['columns']['doktype']['config']['items'][] = array(
'Shortlink',
$customShortlinkDoktype,
$customPageIcon
);
// Also add the new doktype to the page language overlays type selector (so that translations can inherit the same type)
$GLOBALS['TCA']['pages_language_overlay']['columns']['doktype']['config']['items'][] = array(
'Shortlink',
$customShortlinkDoktype,
$customPageIcon
);
// Add the icon for the new doktype
\TYPO3\CMS\Backend\Sprite\SpriteManager::addTcaTypeIcon('pages', $customShortlinkDoktype, $customPageIcon);
// Add the new doktype to the list of types available from the new page menu at the top of the page tree
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addUserTSConfig(
'options.pageTree.doktypesToShowInNewPageDragArea := addToList(' . $customShortlinkDoktype . ')'
);
@einpraegsam
Copy link

For such who also search in 8.7 or newer - see T3 documentation under https://docs.typo3.org/typo3cms/CoreApiReference/PageTypes/Index.html

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment