Ich versuche ein Accordion mit Content-Blocks zu bauen.
Ich möchte das jedes Accordion-Element mehrere TYPO3 Inhaltselemente aufnehmen kann. So was in dieser Art:
- Accordion Item 1
-- Text mit Bild
-- Text
- Accordion Item 2
- Accordion Item 3
Das ist meine config.yaml:
name: awagner/accordion
typeName: awagner_accordion
group: default
prefixFields: false
prefixType: full
basics:
- TYPO3/Links
- TYPO3/Categories
fields:
- identifier: accordioncollection
type: Collection
labelField: text
minitems: 1
appearance:
collapseAll: true
levelLinksPosition: both
fields:
- identifier: text
type: Text
- identifier: accordion_item
label: "Accordion Inhalt"
type: Collection
minitems: 1
appearance:
collapseAll: true
levelLinksPosition: both
foreign_table: tt_content
overrideChildTca:
columns:
CType:
config:
default: text
Mein Frontend funktioniert bereits soweit, dass ich die Accordion-Elemente anzeigen lasse.
<html xmlns:f="http://typo3.org/ns/TYPO3/Fluid/ViewHelpers" data-namespace-typo3-fluid="true">
<f:spaceless>
<div class="accordion accordion-modern" id="accordion">
<f:for each="{data.accordioncollection}" as="accordionItem" iteration="i">
<div class="card card-default">
<div class="card-header">
<h4 class="card-title m-0">
<a class="accordion-toggle text-color-dark font-weight-bold"
data-bs-toggle="collapse"
data-bs-parent="#accordion"
href="#acc-{data.uid}-{i.index}">
<i class="icons icon-question text-color-primary"></i>
{accordionItem.text}
</a>
</h4>
</div>
<div id="acc-{data.uid}-{i.index}" class="collapse">
<div class="card-body text-2">
<f:for each="{accordionItem.accordion_item}" as="child">
<f:debug>{child}</f:debug>
</f:for>
</div>
</div>
</div>
</f:for>
</div>
</f:spaceless>
</html>
Das HTML zeigt alle Elemente der ersten Ebene an und ich kann die Elemente auch aufklappen. Die Ausgabe von <f:debug>{child}</f:debug> wirft mir auch die in den Elementen untergebrachten Inhaltselemente aus.
TYPO3\CMS\ContentBlocks\DataProcessing\ContentBlockDataprototypeobject
_record => protectedTYPO3\CMS\Core\Domain\Recordprototypeobject
_name => protected'core/text' (9 chars)
_grids => protectedNULL
_processed => protectedarray(19 items)
uid => 18 (integer)
pid => 9 (integer)
frame_class => 'default' (7 chars)
colPos => 0 (integer)
CType => 'text' (4 chars)
categories => TYPO3\CMS\Core\Collection\LazyRecordCollectionprototypeobjectsee above
(empty)
layout => 0 (integer)
space_before_class => '' (0 chars)
space_after_class => '' (0 chars)
date => NULL
header => '' (0 chars)
header_layout => 0 (integer)
header_position => '' (0 chars)
header_link => TYPO3\CMS\Core\LinkHandling\TypolinkParameterprototypeobjectsee above
subheader => '' (0 chars)
bodytext => '<p>Test</p>' (11 chars)
sectionIndex => 1 (integer)
linkToTop => 0 (integer)
tx_container_parent => NULL
Wie gebe ich denn jetzt dieses Element aus?