Skip to content

Commit 539776c

Browse files
authored
Update create page type documentation (#5341)
1 parent e1befde commit 539776c

File tree

3 files changed

+74
-36
lines changed

3 files changed

+74
-36
lines changed

Documentation/ApiOverview/PageTypes/CreateNewPageType.rst

Lines changed: 61 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -16,58 +16,83 @@ the directions below to the end:
1616
.. versionchanged:: 12.0
1717
A new :php:`PageDoktypeRegistry` was introduced replacing the
1818
:php:`$GLOBALS['PAGES_TYPES']` array. Use the version selector to look up
19-
the syntax in the corresponding documentation version for older TYPO3 versions.
19+
the syntax in the corresponding documentation version for older
20+
TYPO3 versions.
2021

21-
The first step is to add the new page type to the
22-
:php:`\TYPO3\CMS\Core\DataHandling\PageDoktypeRegistry`. Then you need to add
23-
the icon chosen for the new page type and allow users to drag and drop the new
24-
page type to the page tree.
22+
.. rst-class:: bignums
2523

26-
The new page type is added to the :php:`PageDoktypeRegistry` in
27-
:file:`ext_tables.php`:
24+
1. Add new page type to :php:`PageDoktypeRegistry`
2825

29-
.. literalinclude:: _ext_tables.php
30-
:language: php
31-
:caption: EXT:examples/ext_tables.php
26+
The new page type has to be added to the
27+
:php:`\TYPO3\CMS\Core\DataHandling\PageDoktypeRegistry`. TYPO3 uses this
28+
registry internally to only allow specific tables to be inserted on that
29+
page type. This registry will not add or modify any TCA. In example below
30+
all kind of tables (`*`) are allowed to be inserted on the new page type.
3231

33-
We need to add the following :ref:`user TSconfig <t3tsref:usertsconfig>`
34-
to all users, so that the new page type is displayed in the wizard:
32+
The new page type is added to the :php:`PageDoktypeRegistry` in
33+
:file:`ext_tables.php`:
3534

36-
.. literalinclude:: _user.tsconfig
37-
:language: typoscript
38-
:caption: EXT:examples/Configuration/user.tsconfig
35+
.. literalinclude:: _ext_tables.php
36+
:language: php
37+
:caption: EXT:examples/ext_tables.php
3938

40-
The :ref:`icon <icon>` is registered in :file:`Configuration/Icons.php`:
39+
2. Add an icon chosen for the new page type
4140

42-
.. literalinclude:: _Icons.php
43-
:language: php
44-
:caption: EXT:examples/Configuration/Icons.php
41+
You need to add the icon chosen for the new page type and allow users to
42+
drag and drop the new page type to the page tree.
4543

46-
Furthermore we need to modify the configuration of page records. As one can modify the pages, we
47-
need to add the new doktype as an select option and associate it with the configured icon. That is done in
48-
:file:`Configuration/TCA/Overrides/pages.php`:
44+
We need to add the following :ref:`user TSconfig <t3tsref:usertsconfig>`
45+
to all users, so that the new page type is displayed in the wizard:
4946

47+
.. literalinclude:: _user.tsconfig
48+
:language: typoscript
49+
:caption: EXT:examples/Configuration/user.tsconfig
5050

51-
.. literalinclude:: _pages.php
52-
:language: php
53-
:caption: EXT:examples/Configuration/TCA/Overrides/pages.php
51+
The :ref:`icon <icon>` is registered in :file:`Configuration/Icons.php`:
5452

55-
As you can see from the example, to make sure you get the correct icons,
56-
you can utilize :php:`typeicon_classes`.
53+
.. literalinclude:: _Icons.php
54+
:language: php
55+
:caption: EXT:examples/Configuration/Icons.php
5756

58-
It is possible to define additional type icons for special case pages:
57+
It is possible to define additional type icons for special case pages:
5958

60-
* Page contains content from another page `<doktype>-contentFromPid`,
61-
For example: :php:`$GLOBALS['TCA']['pages']['ctrl']['typeicon_classes']['116-contentFromPid']`.
62-
* Page is hidden in navigation `<doktype>-hideinmenu`
63-
For example: :php:`$GLOBALS['TCA']['pages']['ctrl']['typeicon_classes']['116-hideinmenu']`.
64-
* Page is the root of the site `<doktype>-root`
65-
For example: :php:`$GLOBALS['TCA']['pages']['ctrl']['typeicon_classes']['116-root']`.
59+
* Page contains content from another page `<doktype>-contentFromPid`,
60+
For example: :php:`$GLOBALS['TCA']['pages']['ctrl']['typeicon_classes']['116-contentFromPid']`.
61+
* Page is hidden in navigation `<doktype>-hideinmenu`
62+
For example: :php:`$GLOBALS['TCA']['pages']['ctrl']['typeicon_classes']['116-hideinmenu']`.
63+
* Page is the root of the site `<doktype>-root`
64+
For example: :php:`$GLOBALS['TCA']['pages']['ctrl']['typeicon_classes']['116-root']`.
6665

67-
.. note::
66+
.. note::
6867

69-
Make sure to add the additional icons using the :ref:`Icon API <icon>`!
68+
Make sure to add the additional icons using the :ref:`Icon API <icon>`!
7069

70+
3. Add new page type to doktype selector
71+
72+
We need to modify the configuration of page records. As one can modify the
73+
pages, we need to add the new doktype as a select option and associate it
74+
with the configured icon. That is done in
75+
:file:`Configuration/TCA/Overrides/pages.php`:
76+
77+
.. literalinclude:: _pages.php
78+
:language: php
79+
:caption: EXT:examples/Configuration/TCA/Overrides/pages.php
80+
81+
As you can see from the example, to make sure you get the correct icons,
82+
you can utilize :php:`typeicon_classes`.
83+
84+
4. Define your own columns for new page type
85+
86+
By default the new page type will render all columns of default
87+
page type (`DEFAULT (1)`). If you want to chose your own columns you have
88+
to copy over all columns from default page type:
89+
90+
.. literalinclude:: _pagesCopyDefaultPageType.php
91+
:language: php
92+
:caption: EXT:examples/Configuration/TCA/Overrides/pages.php
93+
94+
Now you can modify TCA with Core API like
95+
:php:`ExtensionManagementUtility::addToAllTCAtypes();`
7196

7297
Further Information
7398
-------------------

Documentation/ApiOverview/PageTypes/_pages.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
'group' => 'special',
2020
],
2121
);
22+
2223
// Add the icon to the icon class configuration
2324
$GLOBALS['TCA']['pages']['ctrl']['typeicon_classes'][$customPageDoktype] = $customIconClass;
2425
})();
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<?php
2+
3+
defined('TYPO3') or die();
4+
5+
// encapsulate all locally defined variables
6+
(function () {
7+
// ...code from previous example
8+
9+
// Copy over all columns from default page type to allow TCA modifications
10+
// with f.e. ExtensionManagementUtility::addToAllTCAtypes()
11+
$GLOBALS['TCA']['pages']['types'][116] = $GLOBALS['TCA']['pages']['types'][1];
12+
})();

0 commit comments

Comments
 (0)