-
Notifications
You must be signed in to change notification settings - Fork 397
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[TASK] Update "Create a custom content element type" for TYPO3 v13 (#…
…4720) * [TASK] Update "Create a custom content element type" for TYPO3 v13 The "Extended example" lines 244ff will be adjusted in a followup. Depends on: TYPO3-Documentation/TYPO3CMS-Reference-TCA#1165 Related: https://github.com/TYPO3-Documentation/t3docs-examples/pull/291/files Related: TYPO3-Documentation/Changelog-To-Doc#1013 Related: TYPO3-Documentation/Changelog-To-Doc#801 Releases: main * [TASK] Apply suggestions from code review * Apply suggestions from code review Co-authored-by: Stefan Frömken <froemken@gmail.com> * [TASK] unify CE key --------- Co-authored-by: Stefan Frömken <froemken@gmail.com>
- Loading branch information
Showing
7 changed files
with
109 additions
and
105 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
Documentation/ApiOverview/ContentElements/_AddingYourOwnContentElements/_setup.typoscript
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
lib.contentElement { | ||
templateRootPaths.200 = EXT:my_extension/Resources/Private/Templates/ | ||
templateRootPaths.200 = EXT:my_extension/Resources/Private/Templates/ContentElements/ | ||
} |
6 changes: 3 additions & 3 deletions
6
Documentation/ApiOverview/ContentElements/_AddingYourOwnContentElements/_setup_2.typoscript
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
tt_content { | ||
myextension_newcontentelement =< lib.contentElement | ||
myextension_newcontentelement { | ||
templateName = NewContentElement | ||
myextension_basiccontent =< lib.contentElement | ||
myextension_basiccontent { | ||
templateName = BasicContent | ||
} | ||
} |
47 changes: 25 additions & 22 deletions
47
Documentation/ApiOverview/ContentElements/_AddingYourOwnContentElements/_tt_content.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,32 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
use TYPO3\CMS\Core\Utility\ExtensionManagementUtility; | ||
|
||
defined('TYPO3') or die(); | ||
|
||
// Adds the content element to the "Type" dropdown | ||
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addTcaSelectItem( | ||
'tt_content', | ||
'CType', | ||
[ | ||
// title | ||
'label' => 'LLL:EXT:my_extension/Resources/Private/Language/locallang.xlf:myextension_newcontentelement_title', | ||
// plugin signature: extkey_identifier | ||
'value' => 'myextension_newcontentelement', | ||
// icon identifier | ||
'icon' => 'content-text', | ||
// group | ||
'group' => 'default', | ||
// description | ||
'description' => 'LLL:EXT:my_extension/Resources/Private/Language/locallang.xlf:myextension_newcontentelement_description', | ||
], | ||
'textmedia', | ||
'after', | ||
); | ||
call_user_func(function () { | ||
|
||
$key = 'myextension_basiccontent'; | ||
|
||
// Adds the content element icon to TCA typeicon_classes | ||
$GLOBALS['TCA']['tt_content']['ctrl']['typeicon_classes']['myextension_newcontentelement'] = 'content-text'; | ||
// Adds the content element to the "Type" dropdown | ||
ExtensionManagementUtility::addTcaSelectItem( | ||
'tt_content', | ||
'CType', | ||
[ | ||
'label' => 'Example - basic content', | ||
'value' => $key, | ||
'group' => 'default', | ||
], | ||
'textmedia', | ||
'after', | ||
); | ||
|
||
// ... | ||
// Configure the default backend fields for the content element | ||
$GLOBALS['TCA']['tt_content']['types'][$key] = [ | ||
'showitem' => ' | ||
--palette--;;headers, | ||
bodytext, | ||
', | ||
]; | ||
}); |
29 changes: 0 additions & 29 deletions
29
Documentation/ApiOverview/ContentElements/_AddingYourOwnContentElements/_tt_content_2.php
This file was deleted.
Oops, something went wrong.
13 changes: 13 additions & 0 deletions
13
...on/ApiOverview/ContentElements/_AddingYourOwnContentElements/_tt_content_description.diff
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
ExtensionManagementUtility::addTcaSelectItem( | ||
'tt_content', | ||
'CType', | ||
[ | ||
'label' => 'Example - basic content', | ||
'value' => $key, | ||
+ 'icon' => 'examples-icon-basic', | ||
+ 'description' => 'LLL:EXT:examples/Resources/Private/Language/locallang_db.xlf:basic_content.description', | ||
'group' => 'default', | ||
], | ||
'textmedia', | ||
'after', | ||
); |
12 changes: 12 additions & 0 deletions
12
...mentation/ApiOverview/ContentElements/_AddingYourOwnContentElements/_tt_content_icon.diff
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
ExtensionManagementUtility::addTcaSelectItem( | ||
'tt_content', | ||
'CType', | ||
[ | ||
'label' => 'Example - basic content', | ||
'value' => $key, | ||
+ 'icon' => 'examples-icon-basic', | ||
'group' => 'default', | ||
], | ||
'textmedia', | ||
'after', | ||
); |