Typo3Novice
Typo3Novice

Reputation: 11

How to make a custom content element containing header, bodytext, image from tt_content inline in TYPO3 / TCA overrides?

I want to get an array of custom content objects into my fluid template, so I can build an unordered List.

This is what I want to build:

unordered list of li elements containing image, header, bodytext

In my backend I build a custom element like this:

my custom content element with fields image, header, bodytext from tt_content

What I want to achieve is, that I have a container and in it I can have my custom content element. When expanding it, I can add header, image and bodytext. So that i basically get an array of custom content Elements that I can loop over in my fluid template.

It should look like this:

each entry should be my custom content element with image, header, bodytext when expanding.

Thanks a lot for help!

Upvotes: 0

Views: 466

Answers (2)

Jacco van der Post
Jacco van der Post

Reputation: 618

If you want to do it the TYPO3 way instead of using Grid Elements..

I see you already know how to make a custom content element. To make children within your content element you could make an extra SQL field xxx_foreign.

You need to make 2 content elements. The child you know how to make. The TCA for the inline field of the parent and needed extra colPos in the backendLayout you can find here

Then you will need in typoscript a dataprocessor I will give an example in which the child contains assets (media). In that case you need a nested solution:

        tt_content {
        xxx_education_block < lib.xxxCustomContentElements
        xxx_eheducation_block {
        templateName = xxxEducationBlock
        dataProcessing {
            10 = TYPO3\CMS\Frontend\DataProcessing\DatabaseQueryProcessor
            10 {
                if.isTrue.field = xxx_educations
                table = tt_content
                pidInList.field = pid
                where = xxx_foreign=###uid### AND deleted=0 AND hidden=0
                orderBy = sorting
                markers {
                    uid.field = uid
                }
                as = xxxEducations

                dataProcessing {
                    10 = TYPO3\CMS\Frontend\DataProcessing\FilesProcessor
                    10 {
                        if.isTrue.field = assets
                        references {
                            fieldName = assets
                        }
                        as = assets
                    }
                }
            }
        }
    }
}

To add this to the content wizard:

mod.wizards.newContentElement.wizardItems.blocks {
header = Xxx blokken
after = common

elements {

    xxx_education_block {
        iconIdentifier = content-bullets
        title = XXX - Education intro block
        description =  Introblock xxx
        tt_content_defValues {
            CType = xxx_education_block
        }
    }
}

show := addToList(xxx_education_block)
}

If you do a debug in Fluid you should now be able to iterate over the children and the assets of the children.

Upvotes: 0

Sascha
Sascha

Reputation: 1001

You can use the extension gridelements to create a container that can hold unlimited content elements and use its template to loop over the partial which creates your content element.

Upvotes: 1

Related Questions