Child records of the core
The marks of the records and everything the page module does with them do not depend on Content Blocks. A content element with child records (inline, IRRE) made with the means of the core works the same way. This is the minimum:
Configuration/TCA/Overrides/tt_content.php
use TYPO3\CMS\Core\Utility\ExtensionManagementUtility;
// the field with the records, and a content element type that shows it
$GLOBALS['TCA']['tt_content']['columns']['myext_items'] = [
'label' => 'Teasers',
'config' => [
'type' => 'inline',
'foreign_table' => 'tx_myext_item',
'foreign_field' => 'parent',
],
];
ExtensionManagementUtility::addTcaSelectItem('tt_content', 'CType', [
'label' => 'Teaser list',
'value' => 'myext_teaser',
'group' => 'default',
]);
$GLOBALS['TCA']['tt_content']['types']['myext_teaser'] = [
'showitem' => '--palette--;;general, --palette--;;headers, myext_items, --palette--;;hidden',
];
Copied!
Configuration/TCA/tx_myext_item.php
return [
'ctrl' => ['title' => 'Teaser', 'label' => 'title', 'delete' => 'deleted', 'sortby' => 'sorting'],
'columns' => [
'parent' => ['config' => ['type' => 'number']],
'title' => ['config' => ['type' => 'input']],
// the tag of the heading: a select with tags and nothing else
'tag' => ['config' => ['type' => 'select', 'renderType' => 'selectSingle', 'default' => 'h3', 'items' => [
['label' => 'H2', 'value' => 'h2'],
['label' => 'H3', 'value' => 'h3'],
['label' => 'H4', 'value' => 'h4'],
]]],
'text' => ['config' => ['type' => 'text', 'enableRichtext' => true]],
],
'types' => ['1' => ['showitem' => 'title, tag, text']],
];
Copied!
Resources/Private/Templates/Teaser.html
<f:layout name="Default" />
<f:section name="Main">
<f:for each="{record.myext_items}" as="item">
<article>
<headliner:headline record="{item}">{item -> f:render.text(field: 'title')}</headliner:headline>
{item -> f:render.text(field: 'text')}
</article>
</f:for>
</f:section>
Copied!
- In a template of
fluid_the content element isstyled_ content {data}(an array) and, with the records of its fields resolved,{record}.{record.are the child records as record objects, which is whatmyext_ items} headliner:wants. The layout renders the header of the element, so it needs noheadline headliner:of its own for that.headline - The rules are the same as for Content Blocks (see Content Blocks): the tag field must be a select of tags and nothing else, the
page module finds the rich text of a heading in the text of its record, and the badge is the title of the table
(
ctrl., here Teaser).title - The tag of a record is saved in its own table with the rights of the backend user for it, so the editor needs to be
allowed to modify
tx_.myext_ item